Hi,
I am facing issue while performing Directory Search with CROSS domains. I have two different domains DOMAIN100.LAB and DOMAIN200.LAB . There is no TRUST relationship between these two domains.
My app is running in DOMAIN100.LAB and performing Directory search operation on DOMAIN200.LAB . The application able to bind with DC and able to access properties but Directory search failing with below exception.
Note: It's working fine, if I set the TRUST relation between two domains DOMAIN100.LAB and DOMAIN200.LAB
Exception msg: "The user name or password is incorrect.\r\n"
at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
at System.DirectoryServices.DirectoryEntry.Bind()
at System.DirectoryServices.DirectoryEntry.get_AdsObject()
at System.DirectoryServices.DirectorySearcher.FindAll(Boolean findMoreThanOne)
at System.DirectoryServices.DirectorySearcher.FindAll()
at ConsoleApp1.Program.Main(String[] args) in C:\Users\administrator.DRDOM450\source\repos\MyApp1\ConsoleApp1\Program.cs:line 229
Code : C# code from My app as below: for listing all DCs from Domain DOMAIN200.LAB
string userName = "DOMAIN100\\administrator";
string password = "Control123";
string strDCName = "MYDC201.DOMAIN200.LAB";
try
{
SearchResultCollection results = null;
DirectoryEntry deRootDSE = new DirectoryEntry($"LDAP://{strDCName}/rootDSE", userName, password, AuthenticationTypes.SecureSocketsLayer );
if (null != deRootDSE)
{
string strPath = @"LDAP://" + deRootDSE.Properties["configurationNamingContext"].Value.ToString();
DirectoryEntry de = new DirectoryEntry(strPath, userName, password, AuthenticationTypes.SecureSocketsLayer);
if (null != de)
{
string []strPropList = { "name" };
DirectorySearcher searcher = new DirectorySearcher(de, "(objectcategory=server)", strPropList);
if (null != searcher)
{
results = searcher.FindAll();
}
}
}
}
catch (Exception exxx)
{
Console.WriteLine($"exception {exxx.Message}");
}
Please help to fix the issue.
Thanks & Regards
Prasad