Forum Moderators: coopster

Message Too Old, No Replies

Querying LDAP with php

got some working code, need to adapt it

         

HelenDev

1:33 pm on Sep 23, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have been playing around with some code to pull information out of the LDAP with php. The following code works fine in that it gets some information about a particular user:

$ad = ldap_connect("ldap://ourldapserver.co.uk") or die("Couldn't connect to AD!");
$r=ldap_bind($ad);
$sr=ldap_search($ad, "ou=people,dc=ourcompany,dc=co,dc=uk", "mail=some.user@ourcompany.co.uk");
echo "Number of entires returned is " . ldap_count_entries($ad, $sr) . "<br />";
$info = ldap_get_entries($ad, $sr);
for ($i=0; $i<$info["count"]; $i++) {
echo "Your name is " . $info[$i]["cn"][0] . "<br />";
echo "and your email is " . $info[$i]["mail"][0] . "<br />";
echo "and your username is " . $info[$i]["uid"][0];
}
ldap_close($ad);

I want to adapt this however to retrieve all the members of an email distribution list, for example admin-staff@ourcompany.co.uk. Anyone have any ideas on how I could adapt my existing code to do this?

eelixduppy

5:59 am on Oct 6, 2008 (gmt 0)



Have you found a solution? Any progress?

HelenDev

3:13 pm on Oct 6, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Fraid not, thanks for asking.

It's one of those backburner projects which I've resigned myself to having to write and update the lists and manually - the laborious and boring way!

I'd still be very interested if anyone does have any ideas though!

I don't really know that much about ldap and whether the variable names and things are standard for everyone or whether each IT dept write their own? I haven't yet found a comprehensive reference resource for this.