How to list uid of all the users of LDAP?

Solution 1:

You can specify attributes after your filter, and it will only display those attributes.

E.g.:

ldapsearch -x -LLL uid=* uid > result

This might give you a bunch of uid: 12345 lines. You might then have to pipe it through sed to remove the bit you don't want. (Alternatively, if you do it with perl and Net::LDAP you can extract precisely what you want - but I think ldapsearch + sed is the path of least resistance).