Advertisement

06.08.2008 at 06:02PM PDT, ID: 23467834 | Points: 250
[x]
Attachment Details

Searching for netgroups that a user is a member of in php.

Asked by Klainn in PHP Scripting Language

Tags:

I am attempting to find all the netgroups that a specific userid is a member of.

On a unix box command line I execute the following:
$ ldaplist netgroup nisNetgroupTriple=(,u3x7503,)

And I get the following output as I should:
dn: cn=prt,ou=netgroup,dc=gds,o=lilly.com
dn: cn=verdugo,ou=netgroup,dc=gds,o=lilly.com

In php, I'm using the following code:
                              $netgroup_lookup = array("cn");
                              $netgroup_lookup_filter = "nisNetgroupTriple=".$user_to_search;
                              $netgroup_lookup_result = ldap_search($ld, $ldn, $netgroup_lookup_filter, $netgroup_lookup);
                              $netgroup_lookup_entries = ldap_get_entries($ld, $netgroup_lookup_result);

to search an existing connection to the ldap server that was able to query for a users passwd database information, but won't return any results for a netgroup lookup.

Here's the output from the above code:
Warning: ldap_search() [function.ldap-search]: Search: Bad search filter in /var/www/html/unixcoe/ldap/password/verify.php on line 55

Warning: ldap_get_entries(): supplied argument is not a valid ldap result resource in /var/www/html/unixcoe/ldap/password/verify.php on line 56

and the output from var_dump(ldap_error($ld)); var_dump(ldap_errno($ld));
string(17) "Bad search filter" int(-7)

the formatted search filter is : nisNetgroupTriple=(,u2x9898,) ... so I know it's formatting it correctly. I'm guessing that for some reason it's stuck looking at the password database and not the netgroup database, but I've not given it the passwd or netgroup parameters (ou=peaple or ou=netgroup).

Help! I'm new to php so I hope this is something easy I'm missing.Start Free Trial
[+][-]06.09.2008 at 04:42AM PDT, ID: 21742392

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.09.2008 at 04:47AM PDT, ID: 21742411

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.09.2008 at 05:29AM PDT, ID: 21742624

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.13.2008 at 10:04PM PST, ID: 22957542

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628