Paulinjsh Posted July 25, 2006 Report Share Posted July 25, 2006 Tātad mīlīši vajadzētu padomu kā izdrukāt no AD lietotāju sarakstu (username, group, statussu (aktīvs, bloķēts), e-pastu, full name utt.. ) Izmantoju adldap.sourceforge.net tikai ar ldap un active directory maz esmu ņēmies. Link to comment Share on other sites More sharing options...
Roze Posted July 25, 2006 Report Share Posted July 25, 2006 Hmm nu tur tak ir?! all_users($include_desc,$search,$sorted) Returns all AD users. Link to comment Share on other sites More sharing options...
Paulinjsh Posted July 26, 2006 Author Report Share Posted July 26, 2006 Nu tur atgriež username un description. Nepieciešami vēl citi lauki. Link to comment Share on other sites More sharing options...
Roze Posted July 26, 2006 Report Share Posted July 26, 2006 Jopt nu tu izvēlies kaut kādu gatavu produkta kodu un nemaz nepaskaties kas tur notiek un prasi lai citi dara to tavā vietā.. Atveram adLDAP.php un tur atrodam mūsu nepieciešamas funkcijas kodu: function all_users($include_desc = false, $search = "*", $sorted = true){ // Returns all AD users if ($this->_ad_username!=NULL){ $this->rebind(); } //bind as a another account if necessary if ($this->_bind){ $users_array = array(); //perform the search and grab all their details $filter = "(&(objectClass=user)(samaccounttype=". ADLDAP_NORMAL_ACCOUNT .")(objectCategory=person)(cn=$search))"; $fields=array("samaccountname","displayname"); $sr=ldap_search($this->_conn,$this->_base_dn,$filter,$fields); $entries = ldap_get_entries($this->_conn, $sr); for ($i=0; $i<$entries["count"]; $i++){ if( $include_desc && strlen($entries[$i]["displayname"][0]) > 0 ) $users_array[ $entries[$i]["samaccountname"][0] ] = $entries[$i]["displayname"][0]; else if( $include_desc ) $users_array[ $entries[$i]["samaccountname"][0] ] = $entries[$i]["samaccountname"][0]; else array_push($users_array, $entries[$i]["samaccountname"][0]); } if( $sorted ){ asort($users_array); } return ($users_array); } return (false); } Un redzam ka tur ir $fields=array("samaccountname","displayname"); un palasot http://lv.php.net/ldap_search redzam ka pēc dokumentācijas $filter ir šis funkcijas ceturtais elements $sr=ldap_search($this->_conn,$this->_base_dn,$filter,$fields); tas nozīmē kurus laukus fetchot ( There is an optional fourth parameter, that can be added to restrict the attributes and values returned by the server to just those required. This is much more efficient than the default action (which is to return all attributes and their associated values). The use of the fourth parameter should therefore be considered good practice. ) Tātad vai nu papildinam $fields ar tiem laukiem kurus mums vajag vai arī izmetam vispār laukā un lietojam $sr=ldap_search($this->_conn,$this->_base_dn,$filter); p.s. vispār jau uzskatu ka konkrētais produkts vismaz pētot šo funkciju ir palīks un bloated.. un izvilkt pāris funkcijas kā ldap_connect/_bind/_search_/_get_entries būtu krietni racionālāk un fiksāk.. Link to comment Share on other sites More sharing options...
Paulinjsh Posted July 26, 2006 Author Report Share Posted July 26, 2006 Pats tiko ieraudzīju :D Sorr :D Link to comment Share on other sites More sharing options...
Recommended Posts