LDAP queries
LDAP servers basically hold information for people, such as employees. fields such as uid, cn, sn, givenname, mail, etc hold their ID's, common names, surnames, email addresses, etc.
a simple PHP script can get the email address of someone with last name Snow:
//connect to LDAP server
$host = "127.0.0.1";
$ldapconn = ldap_connect($host);
if ($ldapconn){
//bind to LDAP server
$bind = ldap_bind($ldapconn);
//set filter to get all entries
$dn = "dc=your_domain_name";
//filter to get all entries that have a surname
$filter = "sn=Snow;
$sr = ldap_search($ldapconn,$dn,$filter);
//retrieve entries
$entries = ldap_get_entries($ldapconn,$sr);
//close connection to LDAP
ldap_close($ldapconn);
}
echo "Email address: " . $entries[0]["mail"][0];
a simple PHP script can get the email address of someone with last name Snow:
//connect to LDAP server
$host = "127.0.0.1";
$ldapconn = ldap_connect($host);
if ($ldapconn){
//bind to LDAP server
$bind = ldap_bind($ldapconn);
//set filter to get all entries
$dn = "dc=your_domain_name";
//filter to get all entries that have a surname
$filter = "sn=Snow;
$sr = ldap_search($ldapconn,$dn,$filter);
//retrieve entries
$entries = ldap_get_entries($ldapconn,$sr);
//close connection to LDAP
ldap_close($ldapconn);
}
echo "Email address: " . $entries[0]["mail"][0];
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home