You need to use the ad operation and find an adhelper on the Internet. Code Run the following command to adhelper. enableuser (CommonName ,: Directoryentry entry = Getdirectoryobject ();
Directoryentry subentry = Entry. Children. Find (ldapdn );
Directoryentry deuser = Subentry. Children. Add ( " CN = " + CommonName, " User " );
Deuser. properties [ " Samaccountname " ]. Value = Samaccountname;
Deuser. commitchanges ();
Adhelper. enableuser (CommonName );
Adhelper. setpassword (CommonName, password );
Deuser. Close ();
Return Deuser;
Exception: the server is unwilling to process the request. (The exception comes from hresult: 0x80072035). Haha, it's quite user-friendly, so I don't want
System. directoryservices. directoryservicescomexception was unhandled
Message = " The server is unwilling to process the request. (Exception from hresult: 0x80072035) "
Source = " System. directoryservices "
Errorcode =- 2147016651
Extendederror = 1325
Extendederrormessage = " 0000052d: svcerr: DSID-031A0FC0, problem 5003 (will_not_perform), DATA 0 \ n "
Stacktrace:
In system. directoryservices. directoryentry. commitchanges ()
In leleapplication3.adhelper. enableuser (directoryentry de) Location E: \ Visual Studio 2005 \ Projects \ leleapplication3 \ consoleapplication3 \ adhelper. CS: row number 1168
In leleapplication3.adhelper. enableuser (string CommonName) Location E: \ Visual Studio 2005 \ Projects \ leleapplication3 \ consoleapplication3 \ adhelper. CS: row number 1146
At leleapplication3.adhelper. createnewuser (string ldapdn, string CommonName, string samaccountname, string password) Location E: \ Visual Studio 2005 \ Projects \ leleapplication3 \ consoleapplication3 \ adhelper. CS: row number 812
In leleapplication3.adhelper. createnewuser (string CommonName, string samaccountname, string password) Location E: \ Visual Studio 2005 \ Projects \ leleapplication3 \ consoleapplication3 \ adhelper. CS: row number 842
In leleapplication3.program. Main (string [] ARGs) Location E: \ Visual Studio 2005 \ Projects \ leleapplication3 \ consoleapplication3 \ Program. CS: row number 21
In system. appdomain. nexecuteassembly (Assembly, string [] ARGs)
In Microsoft. visualstudio. hostingprocess. hostproc. runusersassembly ()
In system. Threading. executioncontext. Run (executioncontext, contextcallback callback, object state)
In system. Threading. threadhelper. threadstart ()
After searching for a long time, I cannot figure out the cause. Finally, I put adhelper. setpassword (CommonName, password); In Front Of adhelper. enableuser (CommonName,ProgramYou can pass it. Haha, speechless.