This topic has 1 reply, 2 voices, and was last updated 8 months, 2 weeks ago by Bill Nelson.

  • Author
    Posts
  • #27369
     udbolla
    Participant

    Hi ,

    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
    Uma

    #27370
     Bill Nelson
    Participant

    Search 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 in ldapsearch -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
    done

    I 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.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

©2020 ForgeRock - we provide an identity and access platform to secure every online relationship for the enterprise market, educational sector and even entire countries. Click to view our privacy policy and terms of use.

Log in with your credentials

Forgot your details?