packages/ssoinabox-webui/root/usr/local/share/ssoinabox/htdocs/includes/ldap.php
changeset 8 f68fdcc18df9
parent 4 2212b2ded8bf
equal deleted inserted replaced
5:cdd708efa505 8:f68fdcc18df9
    60 
    60 
    61 function ldap_get_user($username)
    61 function ldap_get_user($username)
    62 {
    62 {
    63 	global $_ldapconn, $ldap_user_basedn;
    63 	global $_ldapconn, $ldap_user_basedn;
    64 	
    64 	
       
    65 	static $cache = array();
       
    66 	if ( isset($cache[$username]) )
       
    67 		return $cache[$username];
       
    68 	
    65 	$search_filter = sprintf("(&(uid=%s)(objectClass=posixAccount))", ldap_escape($username));
    69 	$search_filter = sprintf("(&(uid=%s)(objectClass=posixAccount))", ldap_escape($username));
    66 	
    70 	
    67 	$search_result = ldap_search($_ldapconn, $ldap_user_basedn, $search_filter);
    71 	$search_result = ldap_search($_ldapconn, $ldap_user_basedn, $search_filter);
    68 	if ( ldap_count_entries($_ldapconn, $search_result) !== 1 )
    72 	if ( ldap_count_entries($_ldapconn, $search_result) !== 1 )
    69 		return false;
    73 		return false;
    70 	
    74 	
    71 	return ldap_array_cleanup(ldap_get_attributes($_ldapconn, ldap_first_entry($_ldapconn, $search_result)));
    75 	return $cache[$username] = ldap_array_cleanup(ldap_get_attributes($_ldapconn, ldap_first_entry($_ldapconn, $search_result)));
    72 }
    76 }
    73 
    77 
    74 function ldap_get_group($group)
    78 function ldap_get_group($group)
    75 {
    79 {
    76 	global $_ldapconn, $ldap_group_basedn;
    80 	global $_ldapconn, $ldap_group_basedn;