471,336 Members | 1,428 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,336 software developers and data experts.

Using the DirectoryEntry and DirectorySearcher Classes.

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 = "my****@mysubdomain.mydomain.com";
string Password = "mypassword";

DirectoryEntry de= new
DirectoryEntry(myADSPath,Username,Password,Authent icationTypes.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;
}
Jul 21 '05 #1
1 3886
>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.


You might want to have a close look at the DirectorySearcher's
"ReferralChasing" property - you can set it to various values.

Marc
================================================== ==============
Marc Scheuner May The Source Be With You!
Berne, Switzerland m.scheuner -at- inova.ch
Jul 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Gonçalo Boléo | last post: by
1 post views Thread by Derek Martin | last post: by
5 posts views Thread by ssg31415926 | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.