How to enable Active Directory Accounts using DMS API ?

Document ID : KB000045311
Last Modified Date : 14/02/2018
Show Technical Document Details

Introduction:

Developing application to create Accounts in Active Directory using DMS API with default configuration, the Accounts get created but they will be disabled. So the user cannot use it to login.You need to enable the Accounts manually.

 

To illustrate that, the following code will create an Account, but this one will be disabled:

 

SmDmsUser user = org.newUser(tmpDn);

user.setAttribute("sAMAccountName", username);

user.setAttribute("cn", username);

user.setAttribute("sn","toto");

user.setAttribute("givenname", "toto");

Vector objectclass = new Vector(); 

objectclass.clear();

objectclass.add("top");

objectclass.add("person");

objectclass.add("organizationalPerson");

objectclass.add("user");

user.setAttribute("objectclass", objectclass);

result = user.addObject();

By default the Account is created with the following UserAccountControl attribute : 546 (NORMAL_ACCOUNT (512) + PASSWD_NOTREQD (32) + ACCOUNTDISABLE (2). 

 

Instructions:

You need to add to the code the UserAccountControl attribute to 544 : NORMAL_ACCOUNT (512) + PASSWD_NOTREQD (32) 

user.setAttribute("UserAccountControl ", "544");

 

 Then after the Account creation, the user will be able to login. The Account will be enabled.