This topic has 1 reply, 2 voices, and was last updated 1 year, 3 months ago by Bill Nelson.
-
AuthorPosts
-
January 15, 2020 at 6:17 pm #27369
udbolla
ParticipantHi ,
Can anyone help with a LDAPserach command where we can get all uid’s listed under a DC DN. or a command to get duplicate uid entries in a DC.
Thanks
UmaJanuary 15, 2020 at 6:36 pm #27370Bill Nelson
ParticipantSearch to return all uids beneath a specific base:
ldapsearch -h host.example.com -p 1389 -D “cn=Directory Manager” -w password -b “dc=foo,dc=bar” -s sub “(uid=*)”
if you want to just return the uids (and nothing else) you could do this:
ldapsearch -h host.example.com -p 1389 -D “cn=Directory Manager” -w password -b “dc=foo,dc=bar” -s sub “(uid=*)” | grep “uid: ”
to put them in a sort order so that duplicate uids are next to each other:
ldapsearch -h host.example.com -p 1389 -D “cn=Directory Manager” -w password -b “dc=foo,dc=bar” -s sub “(uid=*)” | grep “uid: ” | sort
There is no way (that I know of) to get a listing of the duplicate uid entries using simply ldapsearch. You could, however, run the results from above through some add’l creative linux commands. For instance, you could take the output of the last command, put it in a looping construct and play with the results:
#!/bin/bash
for i inldapsearch -h host.example.com -p 1389 -D "cn=Directory Manager" -w password -b "dc=foo,dc=bar" -s sub "(uid=*)" | grep "uid: " | sort
do
### do fun stuff here
doneI could write the fun stuff for you too, but where is the fun in that….
ldapsearch has limitations by itself. it is when you combine it with other linux commands or include it in some scripting that you can draw some real power out of its use.
-
AuthorPosts
You must be logged in to reply to this topic.