S
Sezgin Rafed
Hi everyone,
I need to select Users from 2 Domains - one the User has logged into and a
second one, which is a trusted Domain.
There is no problem selecting Users from the Domain the User has logged
into. When trying to query the trusted Domain I get the "a referral was
returned by the server" error message and no results -
SearchResultCollection has no items.
Any help solving the problem will be greatly appreciated. Code snippet
bellow.
Regards.
private void QueryObjects()
{
string myADSPath = "LDAP://DC=mysubdomain,DC=mydomain,DC=com";
string Username = "(e-mail address removed)";
string Password = "mypassword";
DirectoryEntry de= new
DirectoryEntry(myADSPath,Username,Password,AuthenticationTypes.Secure);
DirectorySearcher ds = new DirectorySearcher(de);
ds.PropertyNamesOnly = true;
ds.PropertiesToLoad.Add("name");
Cursor currentCursor = Cursor.Current;
Cursor.Current = Cursors.WaitCursor;
// start searching
SearchResultCollection src = ds.FindAll();
try
{
foreach (SearchResult sr in src)
AddObjectToTree(sr.GetDirectoryEntry()); //adds results to treeview
node
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
src.Dispose();
ds.Dispose();
Cursor.Current = currentCursor;
}
I need to select Users from 2 Domains - one the User has logged into and a
second one, which is a trusted Domain.
There is no problem selecting Users from the Domain the User has logged
into. When trying to query the trusted Domain I get the "a referral was
returned by the server" error message and no results -
SearchResultCollection has no items.
Any help solving the problem will be greatly appreciated. Code snippet
bellow.
Regards.
private void QueryObjects()
{
string myADSPath = "LDAP://DC=mysubdomain,DC=mydomain,DC=com";
string Username = "(e-mail address removed)";
string Password = "mypassword";
DirectoryEntry de= new
DirectoryEntry(myADSPath,Username,Password,AuthenticationTypes.Secure);
DirectorySearcher ds = new DirectorySearcher(de);
ds.PropertyNamesOnly = true;
ds.PropertiesToLoad.Add("name");
Cursor currentCursor = Cursor.Current;
Cursor.Current = Cursors.WaitCursor;
// start searching
SearchResultCollection src = ds.FindAll();
try
{
foreach (SearchResult sr in src)
AddObjectToTree(sr.GetDirectoryEntry()); //adds results to treeview
node
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
src.Dispose();
ds.Dispose();
Cursor.Current = currentCursor;
}