Adding users to the LDAP server

Learn how to add an exemplary test_ldap user on the LDAP server. These steps are required only if LDAP users are not already present and you want to create a new one.


  1. Create a ldif file at any location, as in the following example:
    root@LDAP_SERVER:~#cat test_ldap.ldif
    dn: uid=test_ldap,ou=users,dc=somedomain,dc=com
    uid: test_ldap
    cn: test_ldap
    objectClass: account
    objectClass: posixAccount
    objectClass: top
    loginShell: /bin/bash
    uidNumber: 5036
    gidNumber: 3002
    homeDirectory: /mnt/blumeta0/home/test_ldap
    gecos: test_ldap
    dn: cn=bluusers,ou=groups,dc=somedomain,dc=com
    changetype: modify
    add: memberuid
    memberuid: test_ldap
    memberuid: uid=test_ldap,ou=users,dc=somedomain,dc=com
  2. Add the LDAP user:
    root@LDAP_SERVER:~# ldapadd -h localhost -p 389 -D cn=admin,dc=somedomain,dc=com -w adminpass -c < test_ldap.ldif
    Specifies distinguished name.
    Specifies the password associated with the DN.
    Output follows:
    adding new entry "uid=test_ldap,ou=users,dc=somedomain,dc=com"
    modifying entry "cn=bluusers,ou=groups,dc=somedomain,dc=com"
  3. Add password for the user:
    ldappasswd -h localhost -p 389 -D cn=admin,dc=somedomain,dc=com -w adminpass -S "uid=test_ldap,ou=users,dc=somedomain,dc=com" -s netezzaips
    Specifies the user to change the password for. If you do not use -s <password> option to specify the password, the user will be prompted for new password at their first login.
    Specifies a new password for the user.
  4. Verify if the user is added successfully:
    root@LDAP_SERVER:~#ldapsearch -x -b "dc=somedomain,dc=com" | grep test_ldap
    The output follows:
    memberUid: test_ldap
    memberUid: uid=test_ldap,ou=users,dc=somedomain,dc=com
    # test_ldap, users,
    dn: uid=test_ldap,ou=users,dc=somedomain,dc=com
    uid: test_ldap
    cn: test_ldap
    homeDirectory: /mnt/blumeta0/home/test_ldap
    gecos: test_ldap