Thursday, July 10, 2014

How to refresh your ldap name database in an ldap client

This is useful when, you have a server that is authenticated by ldap. After you have edited something in your ldap server, let's say you have edited a gid for a user, you would find out that it won't be reflected immediately on the client side. So in this case, how would you force your client to accept your newly changed settings? The answer is you need to restart nscd (name service cache daemon):

$ getent passwd pauld

pauld:x:1987:1987:Paul Daniels:/home/pauld:/bin/bash
So after you have made your changes in the server, let's say you want to change pauld's gid to 4000, run the above command again:

$ getent passwd pauld

pauld:x:1987:1987:Paul Daniels:/home/pauld:/bin/bash

Still the changes are not being reflected there. To solve this, simply restart nscd:

$ sudo /etc/init.d/nscd restart

Stopping nscd:                                             [  OK  ]

Starting nscd:                                             [  OK  ]

You should be seeing your change is now updated in the user database:

$ getent passwd pauld

pauld:x:1987:4000:Paul Daniels:/home/pauld:/bin/bash

PS: If for some reason you are still not seeing the new data, you can invalidate the nscd database by:
$ sudo nscd --invalidate=passwd 

where passwd is the name of the table name in nscd database. You can see all available table name in /var/db/nscd 

To look into what is the content of each table, please use strings command:
$ sudo strings /var/db/nscd/passwd

No comments: