本文整理汇总了PHP中ldap_sort函数的典型用法代码示例。如果您正苦于以下问题:PHP ldap_sort函数的具体用法?PHP ldap_sort怎么用?PHP ldap_sort使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ldap_sort函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ldap_call
function ldap_call($connection, $bind_user, $bind_pass, $filter)
{
$ds = ldap_connect($connection);
//echo $connection . $bind_user . $bind_pass . $filter ;
//personal e-mails
if ($ds) {
$r = ldap_bind($ds, $bind_user, $bind_pass);
//$filter="(|(mail= null)(objectCategory=group))";
$sr = ldap_search($ds, "ou=LMC, dc=lamontanita, dc=local", $filter);
ldap_sort($ds, $sr, "cn");
$info = ldap_get_entries($ds, $sr);
//echo $info["count"] . " results returned:<p>";
echo "<table id='ldaptable' border=1><tr><th>Name</th><th>E-mail</th></tr>";
for ($i = 0; $i < $info["count"]; $i++) {
if ($info[$i]["mail"][0] != null) {
echo "<td>" . $info[$i]["cn"][0] . "</td>";
echo "<td>" . $info[$i]["mail"][0] . "</td></tr>";
}
}
echo "</table>";
return $info;
ldap_close($ds);
} else {
echo "<h4>LDAP_CALL unable to connect to LDAP server</h4>";
}
}
示例2: employee_list
/**
* Get all mozComPerson's from LDAP where
* isManager=TRUE AND employeetype!=DISABLED
*
* @return array in the form:
* Array(
* [morgamic@mozilla.com] => Array
(
[cn] => Mike Morgan
[title] => Director of Web Development
[bugzilla_email] => morgamic@gmail.com
)
* , ...
* )
*/
public function employee_list($type = 'all')
{
$this->bind_as_user();
$manager_list = null;
$search_filter = null;
switch (strtolower($type)) {
case 'manager':
$search_filter = '(&(objectClass=mozComPerson)(isManager=TRUE)(!(employeetype=DISABLED)))';
break;
case 'all':
default:
$search_filter = '(&(objectClass=mozComPerson)(!(employeetype=DISABLED)))';
break;
}
$manager_search = $this->ldap_search($search_filter, array("mail", "employeetype", "bugzillaEmail", "cn", "title"));
if ($manager_search) {
ldap_sort($this->ds(), $manager_search, 'cn');
$manager_list = ldap_get_entries($this->ds(), $manager_search);
} else {
kohana::log('error', "LDAP search failed using [{$this->ds()}, {$this->base_dn}, " . "{$search_filter}]" . "LDAP error:[" . ldap_error($this->ds) . "]");
}
$manager_list = $this->flatten_ldap_results($manager_list);
$cleaned_list = array();
foreach ($manager_list as $manager) {
// ensure keys to keep out of isset?:;
$manager = array_merge(array('cn' => null, 'title' => null, 'mail' => null, 'bugzillaemail' => null), $manager);
if (!empty($manager['mail'])) {
$bugzilla_email = !empty($manager['bugzillaemail']) ? $manager['bugzillaemail'] : $manager['mail'];
$cleaned_list[$manager['mail']] = array('cn' => $manager['cn'] ? $manager['cn'] : null, 'title' => $manager['title'] ? $manager['title'] : null, 'bugzilla_email' => $bugzilla_email);
}
}
return $cleaned_list;
}
示例3: change_pass
function change_pass($user, $new_pass)
{
global $config;
global $ldap_connection;
get_ldap_connection($config['user'], $config['pass']);
if ($ldap_connection) {
$filter = "(sAMAccountName={$user})";
$result = ldap_search($ldap_connection, $config['domain_dn'], $filter);
ldap_sort($ldap_connection, $result, "sn");
$info = ldap_get_entries($ldap_connection, $result);
$isLocked = $info[0]["lockoutTime"];
if ($isLocked > 0) {
return msg('account_locked');
}
$userDn = $info[0]["distinguishedname"][0];
$userdata["unicodePwd"] = iconv("UTF-8", "UTF-16LE", '"' . $new_pass . '"');
$result = ldap_mod_replace($ldap_connection, $userDn, $userdata);
if (!$result) {
return msg(ldap_error($ldap_connection));
}
} else {
return msg("wrong_admin");
}
close_ldap_connection();
return "";
}
示例4: parseSearchResult
/**
* Parse the LDAP search results into a nice array
*
* @param resource $searchResult
* @return array
*/
protected function parseSearchResult($searchResult)
{
$result = array();
ldap_sort($this->_directoryServer, $searchResult, $this->_controller->getConfig()->getLdapFirstNameAttribute());
ldap_sort($this->_directoryServer, $searchResult, $this->_controller->getConfig()->getLdapLastNameAttribute());
if (ldap_count_entries($this->_directoryServer, $searchResult)) {
$entries = ldap_get_entries($this->_directoryServer, $searchResult);
for ($i = 0; $i < $entries["count"]; $i++) {
$arr = array('userName' => '', 'firstName' => '', 'lastName' => '', 'emailAddress' => '');
if (!empty($entries[$i][strtolower($this->_controller->getConfig()->getLdapUsernameAttribute())][0])) {
$arr['userName'] = $entries[$i][strtolower($this->_controller->getConfig()->getLdapUsernameAttribute())][0];
}
if (!empty($entries[$i][strtolower($this->_controller->getConfig()->getLdapFirstNameAttribute())][0])) {
$arr['firstName'] = $entries[$i][strtolower($this->_controller->getConfig()->getLdapFirstNameAttribute())][0];
}
if (!empty($entries[$i][strtolower($this->_controller->getConfig()->getLdapLastNameAttribute())][0])) {
$arr['lastName'] = $entries[$i][strtolower($this->_controller->getConfig()->getLdapLastNameAttribute())][0];
}
if (!empty($entries[$i][strtolower($this->_controller->getConfig()->getLdapEmailAddressAttribute())][0])) {
$arr['emailAddress'] = $entries[$i][strtolower($this->_controller->getConfig()->getLdapEmailAddressAttribute())][0];
}
$result[] = $arr;
}
}
return $result;
}
示例5: query_users
public function query_users($filter, $base = '', $attributes = NULL)
{
$attributes = $attributes ? $attributes : $this->fields;
$search = ldap_search($this->ldapconn, $base, $filter, $attributes);
ldap_sort($this->ldapconn, $search, $this->conf["ldap_sort_order"] ? $this->conf["ldap_sort_order"] : "sn");
return ldap_get_entries($this->ldapconn, $search);
}
示例6: AssistedLDAPSearch
function AssistedLDAPSearch($ldapc, $ldap_base, $search_string, $search_limit, $sort_string)
{
// Searching...
$search_result = ldap_search($ldapc, $ldap_base, $search_string, $search_limit);
// Let's see if you could make it
if (!$search_result) {
echo '<div class="error">' . _("An error has ocurred while the system was performing a search: ") . ldap_error($ldapc) . '.<br /><br /><a href="javascript:history.back(1);">' . _("Back") . '</a></div>';
include "../themes/{$app_theme}/footer.php";
die;
}
// Sorting the result by cn
$search_sort = ldap_sort($ldapc, $search_result, $sort_string);
// Let's see if you could make it
if (!$search_sort) {
echo '<div class="error">' . _("There was an error organizing the LDAP search results: ") . ldap_error($ldapc) . '.<br /><br /><a href="javascript:history.back(1);">' . _("Back") . '</a></div>';
include "../themes/{$app_theme}/footer.php";
die;
}
// Getting the all the entries
$search_entries = ldap_get_entries($ldapc, $search_result);
// Let's see if you could make it
if (!$search_entries) {
echo '<div class="error">' . _("There was an error retrieving the LDAP search results: ") . ldap_error($ldapc) . '.<br /><br /><a href="javascript:history.back(1);">' . _("Back") . '</a></div>';
include "../themes/{$app_theme}/footer.php";
die;
}
return $search_entries;
}
示例7: sort
public function sort($key)
{
if (ldap_sort($this->handler, $this->result, $key) === false) {
throw new LdapException(sprintf("Error while sorting results on key '%s'.", $key), $this->handler);
}
return $this;
}
示例8: query_users
function query_users($ldapconn, $filter, $base = '', $attributes, $sort = null)
{
$adapter = new MozillaSearchAdapter();
$conf = $adapter->conf();
$search = ldap_search($ldapconn, $base, $filter, $attributes);
ldap_sort($ldapconn, $search, $sort || $conf["ldap_sort_order"] || "sn");
return ldap_get_entries($ldapconn, $search);
}
示例9: getSearchEntries
public function getSearchEntries()
{
if ($this->ldapConnection && $this->searchResult && $this->maxEntriesToGet >= $this->numEntries) {
ldap_sort($this->ldapConnection, $this->searchResult, 'sn');
return ldap_get_entries($this->ldapConnection, $this->searchResult);
} else {
return false;
}
}
示例10: testAuth
public function testAuth()
{
$adServer = "ldap://10.249.99.50:3268";
$ldap = ldap_connect($adServer);
$username = 'assysit';
//$_POST['username'];
$password = 'mm.2910mm';
//$_POST['password'];
echo " " . $username . " " . $password . "<br>";
if ($username != "" && $password != "") {
$ldaprdn = 'egat' . "\\" . $username;
ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0);
$bind = @ldap_bind($ldap, $ldaprdn, $password);
if ($bind) {
// session_start();
$filter = "(sAMAccountName={$username})";
$result = ldap_search($ldap, "dc=egat,dc=local", $filter);
ldap_sort($ldap, $result, "sn");
$info = ldap_get_entries($ldap, $result);
Log::info("count->" . $info["count"]);
$attributes = ['mail', 'cn', 'c', 'st', 'title', 'description', 'postofficebox', 'physicaldeliveryofficename', 'telephonenumber', 'distinguishedname', 'info', 'memberof', 'department', 'company'];
for ($i = 0; $i < $info["count"]; $i++) {
if ($info['count'] > 1) {
break;
}
// $userlogon= $info[$i]["givenname"][0] ." " . $info[$i]["sn"][0] ." (" . $info[$i]["samaccountname"][0] .")";
Log::info("givenname->" . $info[$i]["givenname"][0]);
//Log::info("sn->".$info[$i]["sn"][0]);
Log::info("samaccountname->" . $info[$i]["samaccountname"][0]);
for ($j = 0; $j < sizeof($attributes); $j++) {
Log::info($j + 1 . " [" . $attributes[$j] . "]->" . $info[$i][$attributes[$j]][0]);
}
//Log::info("givenname->".$info[$i]); // for show attributes
/*
$_SESSION['name']=$info[$i]["givenname"][0];
$_SESSION['sn']=$info[$i]["sn"][0];
$_SESSION['id']=$info[$i]["samaccountname"][0];
*/
//echo '<pre>';
//var_dump($info);
// echo '</pre>';
//$userDn = $info[$i]["distinguishedname"][0];
//header( "location: index.php" );
// exit(0);
}
@ldap_close($ldap);
} else {
// $userlogon="Invalid";
//header( "location: index.php" );
}
} else {
//$userlogon="Invalid";
//header( "location: index.php" );
}
}
示例11: findAll
function findAll($attribute = 'uid', $value = '*', $baseDn = 'ou=People,dc=example,dc=com')
{
$r = ldap_search($this->ds, $baseDn, $attribute . '=' . $value);
if ($r) {
//if the result contains entries with surnames,
//sort by surname:
ldap_sort($this->ds, $r, "sn");
return ldap_get_entries($this->ds, $r);
}
}
示例12: findLargestUidNumber
function findLargestUidNumber()
{
$r = ldap_search($this->ds, $this->baseDn, 'uidnumber=*');
if ($r) {
// there must be a better way to get the largest uidnumber, but I can't find a way to reverse sort.
ldap_sort($this->ds, $r, "uidnumber");
$result = ldap_get_entries($this->ds, $r);
$count = $result['count'];
$biguid = $result[$count - 1]['uidnumber'][0];
return $biguid;
}
return null;
}
示例13: listUsers
/**
* {@inheritdoc}
*/
public function listUsers()
{
if (null === $this->ldapRes) {
$this->connect();
}
$result = ldap_search($this->ldapRes, $this->baseDn, "(mail=*)", array("mail", "uid", "dn"));
ldap_sort($this->ldapRes, $result, 'mail');
$entries = ldap_get_entries($this->ldapRes, $result);
$users = array();
for ($i = 0; $i < $entries['count']; $i++) {
$users[] = array('email' => $entries[$i]['mail'][0], 'username' => $entries[$i]['uid'][0]);
}
return $users;
}
示例14: find
public function find($uri, $justthese = false, $criteria = false)
{
$map = Config::get($uri['concept'], 'OpenLDAP.mapping');
if (!isset($criteria["limit"])) {
$criteria["limit"] = $this->limit;
}
$sr = @ldap_search($this->con, $this->config['context'], self::parseCriteria($criteria, $map), self::parseJustthese($justthese, $map), 0, $criteria["limit"]);
if (!$sr) {
return false;
}
if (isset($criteria["order"])) {
ldap_sort($this->con, $sr, $criteria["order"]);
}
return self::_formatEntries(ldap_get_entries($this->con, $sr), $map);
}
示例15: getUser
private function getUser($user)
{
if (isset($this->dsPointer)) {
$attributes = array('dn', 'givenName', 'sn', 'mail', 'samaccountname', 'memberof');
$query = ldap_search($this->dsPointer, $this->baseDN, "(samaccountname=" . $user . ")", $attributes);
if ($query) {
ldap_sort($this->dsPointer, $query, 'sn');
$result = ldap_get_entries($this->dsPointer, $query);
return $result;
} else {
return null;
}
} else {
return null;
}
}