31 October, 2007

HowTo create LDAP users

LDAP (Lightweight Directory Access Protocol) - not lightweight for my brain.

After some research I found steps how to store users in the LDAP (OpenLDAP server) under Windows.


  1. Change configuration file

    slapd.conf

    ucdata-path ./ucdata
    include ./schema/core.schema
    include ./schema/cosine.schema
    include ./schema/inetorgperson.schema
    include ./schema/misc.schema
    include ./schema/nis.schema
    include ./schema/openldap.schema


    pidfile ./run/slapd.pid
    argsfile ./run/slapd.args

    access to *
    by self write
    by users read
    by anonymous read

    #######################################################################
    # BDB database definitions
    #######################################################################

    database bdb
    suffix "o=sample company"
    rootdn "cn=Manager,o=sample company"
    rootpw secret
    directory ./data
    index objectClass eq

  2. Restart LDAP service

    restart.bat

    net stop OpenLDAP-slapd
    net start OpenLDAP-slapd

  3. Create base record

    base.ldif

    dn: o=sample company
    objectclass: organization
    objectclass: top
    o: sample company

  4. Insert base record into LDAP

    base.bat

    @echo off
    set LDAP_HOME=E:\devenv\tools\OpenLDAP
    set BASE="o=sample company"
    set D=cn=Manager,%BASE%
    set AUTH=-x -w secret -D %D%

    %LDAP_HOME%\ldapadd.exe %AUTH% -a -f base.ldif

  5. Create file with users' definitions

    user.ldif

    dn: cn=Katrien,o=sample company
    objectClass: top
    objectClass: person
    objectClass: inetorgperson
    cn: Katrien
    sn: none
    userPassword: none
    mail: katrien@samplecompany.com

    dn: cn=Gordon,o=sample company
    objectClass: top
    objectClass: person
    objectClass: inetorgperson
    cn: Gordon
    sn: none
    userPassword: none
    mail: Gordon@samplecompany.com

  6. Insert users into LDAP

    user.bat

    @echo off
    set LDAP_HOME=E:\devenv\tools\OpenLDAP
    set BASE="o=sample company"
    set D=cn=Manager,%BASE%
    set AUTH=-x -w secret -D %D%

    %LDAP_HOME%\ldapadd.exe %AUTH% -a -f user.ldif

  7. Check LDAP records

    search.bat

    @echo off
    set LDAP_HOME=E:\devenv\tools\OpenLDAP
    set BASE="o=sample company"
    set D=cn=Manager,%BASE%
    set AUTH=-x -w secret -D %D%

    %LDAP_HOME%\ldapsearch.exe -LLL %AUTH% -b %BASE% "objectClass=person"

No comments: