Search code examples
ldapopenldapldap-queryldifphpldapadmin

How to create LDAP aliases in Openldap and Phpldapadmin?


I am trying to do this example with an email field :

https://coderwall.com/p/c0w6-q/create-ldap-aliases-in-openldap

This is the .ldif that should create both :

# this is the user

dn: uid=aka,c=VN,ou=users,ou=school,o=vdm,dc=domain,dc=com
objectclass: top
objectClass: extensibleObject
objectclass: posixAccount
objectclass: inetOrgPerson
cn: Alexander Fake
employeetype: developer
gecos: Alexander Fake
gidnumber: 14564103
homedirectory: /home/aka
loginshell: /bin/bash
mail: alexander.fake@domain.com
sn: Fake
uid: aka
uidnumber: 14583105
userpassword: {SSHA}SgmdndrPR5UVLOAmDs5JOJvqr3WmPYob

# this is the alias

dn: mail=alexander.Fake@domain.com,dc=mailAccount,dc=domain.com,dc=mail,dc=domain,dc=com
changetype: add
objectClass: alias
objectClass: top
objectClass: extensibleObject
objectclass: inetOrgPerson
uid: aka
aliasedObjectName: uid=aka,c=VN,ou=users,ou=school,o=vdm,dc=domain,dc=com

I can only import/export ldif, I use phpldapadmin for administration.

When the aliases is craeted it produce the following error :

This update has been or will be cancelled, it would result in an attribute value not being unique. You might like to search the LDAP server for the offending entry. 

Does anyone know how to create aliases on openldap and phpldapadmin ?


Solution

  • This is basically correct. Just:

    • Remove the uid=aka attribute from the aliasedObject. It doesn't need it. It refers to another object which has that UID value.
    • Also remove inetOrgPerson from the alias. It isn't a person, it's an alias for a person.
    • The objectClass attribute only needs to contain top and alias; and extensibleObject so you can provide a cn or whatever attribute you like as part of the DN, if you want to do that: it doesn't seem to be necessary judging by my DIT.

    Poor quality source material. Don't rely on arbitrary Internet junk. Use the official documentation.