Creating a User

Before you can create a new user, you first have to obtain such LDAP attributes as:

  • parentDN

  • sAMAccountName

  • cn

  • sn

  • givenName

Once you have obtained these LDAP attributes, follow these steps to create a new user:

  1. Obtain the LDAP attributes necessary for creating a user in Active Directory (for example, parentDN, sAMAccountName, cn, sn, and givenName).

  2. Set up the enrollment data (user attributes) that must be conveyed to ActivID CMS:

    Copy
    EnrollmentDataValue[] enrollmentValue =
    new EnrollmentDataValue[5]; enrollmentValue[0] = new EnrollmentDataValue(); enrollmentValue[0].setId(“parentDN”); enrollmentValue[0].setType(EnrollmentData.
    ENROLLMENT_DATA_TYPE_STRING);
    enrollmentValue[0].setEncoding(EnrollmentData.
    ENROLLMENT_DATA_ENCODING_NONE); enrollmentValue[0].setValue(parentDN); enrollmentValue[1] = new EnrollmentDataValue(); enrollmentValue[1].setId(“sAMAccountName”); enrollmentValue[1].setType(EnrollmentData.
    ENROLLMENT_DATA_TYPE_STRING);
    enrollmentValue[1].setEncoding(EnrollmentData.
    ENROLLMENT_DATA_ENCODING_NONE); enrollmentValue[1].setValue(sAMAccountName); enrollmentValue[2] = new EnrollmentDataValue(); enrollmentValue[2].setId(“cn”); enrollmentValue[2].setType(EnrollmentData.
    ENROLLMENT_DATA_TYPE_STRING);
    enrollmentValue[2].setEncoding(EnrollmentData.
    ENROLLMENT_DATA_ENCODING_NONE); enrollmentValue[2].setValue(cn); enrollmentValue[3] = new EnrollmentDataValue(); enrollmentValue[3].setId(“sn”); enrollmentValue[3].setType(EnrollmentData.
    ENROLLMENT_DATA_TYPE_STRING);
    enrollmentValue[3].setEncoding(EnrollmentData.
    ENROLLMENT_DATA_ENCODING_NONE);
    enrollmentValue[3].setValue(sn); enrollmentValue[4] = new EnrollmentDataValue(); enrollmentValue[4].setId(“givenName”); enrollmentValue[4].setType(EnrollmentData.
    ENROLLMENT_DATA_TYPE_STRING);
    enrollmentValue[4].setEncoding(EnrollmentData.
    ENROLLMENT_DATA_ENCODING_NONE);
    enrollmentValue[4].setValue(givenName);
  3. Instantiate a user ID object using the LDAP attribute sAMAccountName:

    Copy
    UserId userId = new UserId(sAMAccountName);
  4. Instantiate a User object using the enrollment data and the user ID:

    Copy
    User user = new User(userId, enrollmentValue);
    Note: The unicodePwd attribute (user password) can only be changed if the connection to the Active Directory is secured using SSL or LDAPS (LDAP over SSL).
  5. Use the createUser method of the UserManager class to create a new user:

    Copy
    userMgr.createUser(user);