Re: Search for member of a groupOfNames group

[email protected] (Clément OUDOT) Wed, 9 Jan 2013 15:51:23 +0100
Newsgroups perl.ldap
Message-ID <CAK_oV48tNBcxP-SbiaYtOYSVq-AhC9kSQ0ywZLqm4yHRaqJzxg@mail.gmail.com>
2013/1/7 Brian Gaber <[email protected]>:
> I have OpenLDAP ldap with many groupOfNames groups. I want to determine if a user is a member of a specific group.
>
> I would like return a True or False whether user is a member of group or not.

You can use the compare operation. See perldoc Net::LDAP :

       compare ( DN, OPTIONS )
           Compare values in an attribute in the entry given by "DN"
on the server. "DN" may be a string or a
           Net::LDAP::Entry object.

           attr => ATTR
               The name of the attribute to compare.

           value => VALUE
               The value to compare with.

           control => CONTROL
           control => [ CONTROL, ... ]
               See "CONTROLS" below.

           callback => CALLBACK
               See "CALLBACKS" below.

           Example

             $mesg = $ldap->compare( $dn,
                                     attr  => 'cn',
                                     value => 'Graham Barr'
                                   );


Clément.