question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

New User Not Enabled Upon Creation

See original GitHub issue

When I create a new user in Active Directiory, it is disabled until I manually reset the password and enable them (using ADUC).

I am using the following approach:

  client.add ( userDn, entry, function (err, result) { console.log(err, result); }  } );

With the following entry object:

    var entry = {
    displayName: displayName,   
    sAMAccountName: samAccountName,     
    name: name,
    sn: name,
    givenName: givenName,
    mailNickname: samAccountName,
    userPrincipalName: userPrincipalName, 
    physicalDeliveryOfficeName: officeName,     
    company: company,   
    info: sourceInfo,   
    department: locationCode,   
    mail: [email],
    objectClass: ['organizationalPerson', 'person', 'top', 'user'],
    objectCategory: personCategory
    description: 'auto created on ' + (new Date()).toLocaleString()
  }

If I attempt to add in the userPassword property, the process will return a [UnwillingToPerformError] with a 5003 WILL_NOT_PERFORM code.

I have tried to use the iconv-lite library to encode in utf16-le and I have tried the node-ssha256 found in the only references that I could dig up.

According to this powershell reference, the account is disabled because I am not able to supply the proper secureString password with the account:

   -AccountPassword SecureString
       A new password value for an account.
       This value is stored as an encrypted string.
       If an empty or $null password is specified a Random password will be set.
       If the password does not meet password policy the account will be disabled

       User accounts, by default, are created without a password.
       A valid user account password may also be specified manually.
       User accounts will never be enabled unless a valid password is set

       The following example will prompt for a password.
          -AccountPassword (Read-Host -AsSecureString "AccountPassword")

Adding a userAccountControl: 512 to the object to enable the account upon creation also fails.

Calling a modify from the creation callback also fails. And, this is using a password that is compliant with the enforced policies.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:7

github_iconTop GitHub Comments

2reactions
djolson11commented, Feb 26, 2020

I know this is old, but I was able to get a user created and enabled by passing

userAccountControl: “512”

as a property. I cannot pass a password either though, which is part of your issue. So if you use the userAccountControl without the password, it creates the user with a blank password that needs to be reset upon first login.

0reactions
guenthergmbhcommented, Apr 19, 2020

As it was mentioned, first of all you need to make sure that your Domain Controller accepts connections via ldaps. Otherwise you are not able to store or change passwords at all. Secondly the passwords are stored in the field unicodePwd and need to be encoded. I am doing that as follows:

encodePassword(password) {
   let newPassword = '';
   password = "\"" + password + "\"";
   for (let i = 0; i < password.length; i++) {
      newPassword += String.fromCharCode(password.charCodeAt(i) & 0xFF,(password.charCodeAt(i) >>> 8) & 0xFF);
   }
   return newPassword;
}

So my entry object looks like:

distinguishedName: `cn=${this.user.username},ou=mytestou,dc=mydomain,dc=com`,
cn: this.user.username,
givenName: this.user.givenName,
sn: this.user.surname,
displayName: `${this.user.surname}, ${this.user.givenName}`,
mail: `${this.user.username}@mydomain.com`,
uid: this.user.username,
userPrincipalName: `${this.user.username}@mydomain.com`,
sAMAccountName: this.user.username,
objectClass: ['top', 'person', 'organizationalPerson', 'user'],
userAccountControl:'512',
unicodePwd: this.encodePassword(this.user.password)

Hope this helps.

Side note: You should not install your certificate authority on your DC. Just get an independent server for that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

New User Not Enabled Upon Creation · Issue #342 - GitHub
When I create a new user in Active Directiory, it is disabled until I manually reset the password and enable them (using ADUC)....
Read more >
Active Directory User which can Create a User but not Allowed ...
Hi Guys, we have a requirement to create a User Group in Active Directory which will grant its members permission to 'Create Users'...
Read more >
New User Creation - Do not Generate an email to the user
Hi all below code works for creating user and generating welcome email, Profile p = [SELECT Id FROM Profile WHERE Name='Standard User']; System....
Read more >
PowerShell New-ADUser creating disabled user anyways
If that fails, the newly created user is disabled, not removed and the ADPasswordComplexityException is never thrown when using the New-ADUser ...
Read more >
Active Directory or LDAP sync is not creating new users or ...
Make sure that the newly created users have values for all of the attributes configured on the Jira Directory integration at the Active ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found