In ASP.NET, I use C # to AD operation, add users

xiaoxiao2021-03-06  15

Theme: About AD, Master Please go, online waiting in ASP.NET, I use C # to do AD operations, add users, how can I list all users below the domain, including Uses, and organizational units you have established. Please give example, thank you

Reply to: yxrj () () Reputation: 105 2002-07-23 09: 38: 35Z score: 50? DirectoryEntry Objde;

// list users

Objde = New DirectoryEntry ("LDAP: // Yourserver / CN = Users, DC = XXX, DC = COM", "Administrator", "PWD", System.directoryServices.AuthenticationTypes.serverbind;

Foreach (DirectoryEntry Chin Objde.Children)

Response.write (ch.path "" ch.schemaclassname ");

// Construction users

DirectoryEntry Objde1 = objde.children.add ("cn = newtest", "user");

Objde1.invoke ("put", new object [2] {"givenname", "newtest"});

Objde1.invoke ("put", new object [2] {"samaccountname", "newtest"});

Objde1.invoke ("put", new object [2] {"UserPrincipalName", "newtest"});

Objde1.invoke ("Put", new object [2] {"UseraccountControl", "512"});

Objde1.commitchanges ();

Objde1.invoke ("ChangePassword", New Object [2] {"," PWD "});

Objde1.commitchanges ();

TOP

Reply to: yxrj () () Reputation: 105 2002-07-23 10: 15: 29Z score: 50? If you want to find User under all contavers, use DirectorySearcher

DirectoryEntry Objde = New DirectoryEntry ("LDAP: // YourServer", "Administrator", "PWD", System.directoryServices.AuthenticationTypes.Serverb);

System.directoryServices.directorySearcher MySearcher = new system.directoryServices.directorySearcher (Objde);

Mysearcher.filter = ("(ObjectClass = User);

Foreach (System.directoryServices.searchResult Resent in Mysearcher.findall ())

{

Response.write (Resent.path "

");

}

TOP

Reply to: yxrj () () Reputation: 105 2002-07-23 10: 22: 49Z score: 0? If you want to find User under all contavers, DirectorySearCherDirectoryEntry Objde = New DirectoryEntry ("ldap: // Yourserver", " Administrator, "PWD", System.directoryServices.AuthenticationTypes.serverbind);

System.directoryServices.directorySearcher MySearcher = new system.directoryServices.directorySearcher (Objde);

Mysearcher.filter = ("(ObjectClass = User);

Foreach (System.directoryServices.searchResult Resent in Mysearcher.findall ())

{

Response.write (Resent.path "

");

}

TOP

Reply to: Richard2001 (Richard) () Reputation: 98 2002-07-23 10: 30: 27Z score: 0? I also try.

TOP

Reply to: cuiaimin (shadow) () Reputation: 99 2002-07-23 10: 54: 37Z score: 0? Thank you YXRJ

TOP

Reply to: AMENG_2002 (Flyfox) () Reputation: 105 2002-07-23 11: 09: 33Z score: 0? Gz

TOP

Reply to: Ketao_78 (tree wants and the wind) () reputation: 101 2002-07-23 14: 20: 45Z score: 0? Wow, this is really powerful enough

转载请注明原文地址:https://www.9cbs.com/read-46590.html

New Post(0)