How to delete a user from the LDAP container

Baini.Marouane picture Baini.Marouane · Jun 20, 2017 · Viewed 11.1k times · Source

I need to delete a user from the LDAP container.

First of all I searched for the user using :

$ ldapsearch -x -b "dc=tuleap,dc=local" -s sub "objectclass=*"

I found the user and than I execute :

$ ldapdelete  -v -D "uid=user,dc=tuleap,dc=local" -w userpassword

I get this :

ldap_initialize( DEFAULT )
ldap_bind: Invalid credentials (49)

Any one can help to resolve this issue.

Answer

Esteban picture Esteban · Jun 21, 2017

From what you put in your comments, the error Invalid credentials (49) comes from the incorrect DN you provided for your user :

uid=user,dc=tuleap,dc=local instead of uid=user,ou=people,dc=tuleap,dc=local

Now for the syntax of your command, you have to specify which entry you want to delete from the directory.

From the documentation :

If one or more DN arguments are provided, entries with those Distinguished Names are deleted. Each DN should be provided using the LDAPv3 string representation as defined in RFC 4514

For example :

ldapdelete -v -D "uid=user,ou=people,dc=tuleap,dc=local" -W "uid=user2,ou=people,dc=tuleap,dc=local"

Which will try to delete the entry : uid=user2,ou=people,dc=tuleap,dc=local