c# Active Directory connect directly to user DN

A

AdamKadmon

Hello there. I have a method that pulls out the members of a group in
the form of distinguishedName. I read somewhere that I could then
connect to the Directory with:
DirectoryEntry(@"LDAP://servername/" + dnPulledFromGroup)
and somehow pull the user CN in this fashion. Could someone point me
in the direction of how this might be achieved? I have tried a few
things, but am running into walls left and right.

Thanks,

Adam
 
M

Marc Scheuner [MVP ADSI]

Hello there. I have a method that pulls out the members of a group in
the form of distinguishedName. I read somewhere that I could then
connect to the Directory with:
DirectoryEntry(@"LDAP://servername/" + dnPulledFromGroup)
and somehow pull the user CN in this fashion. Could someone point me
in the direction of how this might be achieved?

It won't work - where did you read that??

If you have only the user's RDN (relative distinguished name, e.g.
"CN=John Doe"), there's no way to just "bind" to that user - after
all, that user could be ANYWHERE in your AD tree!

What you can do is do a search for that user, based on this RDN - set
up a DirectorySearcher, set the start location, and use that RDN as a
search criteria on the "distinguishedName" attribute. That should
work. You would then get back whatever attributes from the user that
you need - or the whole DirectoryEntry for that user, if need be.

HTH
Marc
 

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