c# - System.DirectoryServices use And limitation -


in application need fetch users email active directory.

i came across system.directoryservices namespace accessing active directory. have no idea on how works. have few questions.

can use namespace , access ad proper queries? there pre-requisite access ldap etc.

please let me know how works

fyi use .net 4.0

if you're on .net 3.5 , up, should check out system.directoryservices.accountmanagement (s.ds.am) namespace. read here:

basically, can define domain context , find users and/or groups in ad:

// set domain context using (principalcontext ctx = new principalcontext(contexttype.domain)) {    // find user    userprincipal user = userprincipal.findbyidentity(ctx, "someusername");     if(user != null)    {       // here....          }     // find group in question    groupprincipal group = groupprincipal.findbyidentity(ctx, "yourgroupnamehere");     // if found....    if (group != null)    {        // iterate on members        foreach (principal p in group.getmembers())        {           console.writeline("{0}: {1}", p.structuralobjectclass, p.displayname);           // whatever need members        }     } } 

the new s.ds.am makes easy play around users , groups in ad!


Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -