Re: ldap_search()

From: Date: Thu, 08 Mar 2001 08:21:15 +0000
Subject: Re: ldap_search()
Groups: php.general 
Request: Send a blank email to php-general+get-43009@lists.php.net to get a copy of this message
Mike The purpose of setting the basedn is to say "search in this branch of the directory". The only person who can really tell you what basedn to use is whoever designed or manages the structure of your LDAP server. Having said that, a base dn is commony something like ... o=Your Organisation,c=US Some LDAP managers also make consistent use of the "ou" or "organizationalUnit" attribute to provide a further logical division of the directory. If your directory is organised this way, and you want to restrict your search to just one ou in the organisation, you might set the basedn for the search to be ou=Whatever Section,o=Your Organisation,c=US HTH Nick Talbott IT Policy and Strategy Manager, Powys County Council, UK email nickt@powys.gov.uk FAX +44 (0) 1597 824781 web http://www.powys.gov.uk and http://www.powysweb.co.uk -----Original Message----- From: Mike Tuller <mitull01@willy.wsc.edu> To: php mailing list <php-general@lists.php.net> Date: 08 March 2001 01:03 Subject: [PHP] ldap_search() >Sorry about this, but I don't know much about LDAP, and the book I have >doesn't tell me much. > >I was shown the following script to grab information from an LDAP server and >display the results in a phonebook type format. > ><HTML> ><BODY> ><?php >$ldapserver = "ldap.something.com"; >$basedn = "dc=something, dc=com"; > >$dir =ldap_connect($ldapserver); // Connect to server > >if ($dir) { > ldap_bind($dir); // Bind to the server > $result = ldap_search($dir, $basedn, "sn=*"); // query connection, set >the base and look for any sn > > $info = ldap_get_entries($dir, $result); // The results get sent to the >$info object > > for ($i=0; $i<$info["count"]; $i++) { // Count is a ldap feature that >contains the length of the resultset > echo $info[$i]["cn"][0]; // choose any parameter you want see here > } > > ldap_close($dir); >} >?> ></BODY> ></HTML> > > >The problem I am running into I think is that I work for a school district, >and I don't have a .com address. I have anoka.k12.mn.us. I tried to put in >$basedn = "dc=anoka, dc=k12, dc=mn, dc=us"; but I still receive an error on >ldap_search. Am I doing this correctly? > >Mike > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net >For additional commands, e-mail: php-general-help@lists.php.net >To contact the list administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.general (#43009) next »