Understaing NET::LDAP

Discussion in 'Perl Misc' started by Michael Hill, Aug 3, 2004.

  1. Michael Hill

    Michael Hill Guest

    I have a LDAP query like:

    my $basedn = "ou=people,o=myhost.com";
    my $scope = "sub";
    my $filter = "manager=uid=fred,ou=people,o=myhost.com";

    $searchobj = $conn->search( base=>$basedn, scope=>$scope,
    filter=>$filter, attrs=>$attrs );

    my $max = $searchobj->count;

    ## iterate through the hash
    for($i = 0 ; $i < $max ; $i++)
    {
    my $entry = $searchobj->entry($i);
    foreach my $attr ($entry->attributes)
    {
    #iterate over the fields
    }
    }

    Only thing is that I'd like to limit the records being returned.

    The object "manager" could look like either
    ex1:
    uid=fred,ou=people,o=myhost.com
    uid=fred_boss,ou=people,o=myhost.com
    uid=fred_boss_boss,ou=people,o=myhost.com
    ex2:
    uid=works_for_fred,ou=people,o=myhost.com
    uid=fred,ou=people,o=myhost.com
    uid=fred_boss,ou=people,o=myhost.com
    uid=fred_boss_boss,ou=people,o=myhost.com

    So .... since I am searching for "uid=fred,ou=people,o=myhost.com" I get
    both rows.

    I can limit the output in the "foreach" step, but I'd like to limit the
    number of records matching the search in the filter so the script
    processes quicker.

    Anyone have any idea how to enhance the filter further?

    Mike
     
    Michael Hill, Aug 3, 2004
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.