LDAP path to server and a user group

G

Guest

I am trying to create an LDAP connection.

I have managed to connect to "LDAP://myServerName"

I now want to connect further down the directory tree, to a particular user
group.
I have tried "LDAP://myServerName/OU=myUserGroup" but get a "An operations
error occured" error.

How can i do this?

many thanks,

razor
 
S

Siva M

One way to reach the group is to first connect to the LDAP and do a
directory search for the group.

DirectoryEntry ent = new DirectoryEntry(LDAP://myServerName);
DirectorySearcher srch = new DirectorySearcher("(CN=" + strGroup + ")");
SearchResult sr = srch.FindOne();
DirectoryEntry myGroup = sr.GetDirectoryEntry();

Another way is to directly connect to the group as in:

DirectoryEntry ent = new DirectoryEntry(LDAP://CN=GroupName, DC=domain);

Hope this helps?

I am trying to create an LDAP connection.

I have managed to connect to "LDAP://myServerName"

I now want to connect further down the directory tree, to a particular user
group.
I have tried "LDAP://myServerName/OU=myUserGroup" but get a "An operations
error occured" error.

How can i do this?

many thanks,

razor
 
W

Willy Denoyette [MVP]

You can directly bind to any object in the AD, there is no need to search
for something you know it exists.

For example, "LDAP://CN=<group name>, CN =<Users>, DC=<domain component>,
DC=<domain component>,...".

or..

"LDAP://domain/CN=<group name>, CN =<Users>, DC=<domain component>,
DC=<domain component>,...".

or..

"LDAP://DomainControler/CN=<group name>, CN =<Users>, DC=<domain
component>, DC=<domain component>,...".


All bind to the same object in the AD, one by connecting to the default
login domain, the next by connecting to a specific domain and the last one
by connecting to a specific server (a DC).

I would suggest the OP to read the documentation about ldap and ADSI in MSDN
before starting to do anything against an AD domain.

Willy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top