/// <summary> /// Create a user to AD. /// </summary> /// <param name="ldapConnectionInfo">The LDAP connection information</param> /// <param name="adUser">The user record to be created</param> /// <param name="Password">Passes two parameters to this task: bool setPassword, which defines if a password should be set at create time, and string newPassword, containing the password to be set.</param> /// <returns>LdapResult class, which carries a copy of the created user record.</returns> public static OutputUser AD_CreateUser([PropertyTab] LdapConnectionInfo ldapConnectionInfo, [PropertyTab] CreateADuser adUser, AD_CreateUserProperties Password) { var ldapOperationResult = new OutputUser { operationSuccessful = false, user = null }; using (var ldap = new LdapService(ldapConnectionInfo)) { ldapOperationResult.user = ldap.CreateAdUser(adUser); if (Password.setPassword) { SetPassword.SetUserPassword(ldapConnectionInfo.LdapUri, adUser.Path, ldapConnectionInfo.Username, ldapConnectionInfo.Password, adUser.CN, Password.newPassword); } ldapOperationResult.operationSuccessful = true; return(ldapOperationResult); } }