当前位置: 首页>>代码示例>>PHP>>正文


PHP ldap_get_entries函数代码示例

本文整理汇总了PHP中ldap_get_entries函数的典型用法代码示例。如果您正苦于以下问题:PHP ldap_get_entries函数的具体用法?PHP ldap_get_entries怎么用?PHP ldap_get_entries使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ldap_get_entries函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: lookup

 public static function lookup($query, $type)
 {
     $person_array = array();
     $x500 = ldap_connect('ldap.utexas.edu');
     $bind = ldap_bind($x500);
     $dn = "ou=people,dc=directory,dc=utexas,dc=edu";
     $filter = "{$type}={$query}";
     $ldap_result = @ldap_search($x500, $dn, $filter);
     $attributes = array('eid' => 'uid', 'email' => 'mail', 'name' => 'cn', 'firstname' => 'givenname', 'lastname' => 'sn', 'office' => 'utexasedupersonofficelocation', 'phone' => 'telephonenumber', 'title' => 'title', 'unit' => 'ou');
     if ($ldap_result) {
         $entry_array = ldap_get_entries($x500, $ldap_result);
         for ($i = 0; $i < count($entry_array) - 1; $i++) {
             $person = array();
             if ($entry_array[$i]) {
                 $eid = $entry_array[$i]['uid'][0];
                 foreach ($attributes as $label => $att) {
                     if (isset($entry_array[$i][$att])) {
                         $person[$label] = $entry_array[$i][$att][0];
                     } else {
                         $person[$label] = '';
                     }
                 }
             }
             $person_array[] = $person;
         }
         ldap_close($x500);
     }
     return $person_array;
 }
开发者ID:pkeane,项目名称:humptydumpty,代码行数:29,代码来源:Utlookup.php

示例2: loadPage

 protected function loadPage()
 {
     if (!ldap_control_paged_result($this->connection, $this->pageSize, true, $this->pageToken)) {
         throw new SearchException("Unable to set paged control pageSize: " . $this->pageSize);
     }
     $search = ldap_search($this->connection, $this->baseDn, $this->filter, is_array($this->attributes) ? $this->attributes : []);
     if (!$search) {
         // Something went wrong in search
         throw Connection::createLdapSearchException(ldap_errno($this->connection), $this->baseDn, $this->filter, $this->pageSize);
     }
     $this->entries = ldap_get_entries($this->connection, $search);
     $this->entriesPosition = 0;
     if (!$this->entries) {
         throw Connection::createLdapSearchException(ldap_errno($this->connection), $this->baseDn, $this->filter, $this->pageSize);
     }
     // check if on first page
     if (empty($this->pageToken)) {
         $this->currentPage = 0;
     } else {
         $this->currentPage++;
     }
     // Ok go to next page
     ldap_control_paged_result_response($this->connection, $search, $this->pageToken);
     if (empty($this->pageToken)) {
         $this->isLastPage = true;
     }
 }
开发者ID:81square,项目名称:ldap,代码行数:27,代码来源:SearchIterator.php

示例3: connect

 public function connect()
 {
     // basic sequence with LDAP is connect, bind, search, interpret search
     // result, close connection
     $ds = ldap_connect("192.168.0.111");
     // must be a valid LDAP server!
     if ($ds) {
         $r = ldap_bind($ds, "portalusr01", "tbs4portal");
         // this is an "anonymous" bind, typically
         if (!$r) {
             echo "Unable to connect to LDAP server";
             die;
         }
         // Search surname entry
         //			$dn = "OU=Users,OU=PT. Monica Hijau Lestari,DC=thebodyshop,DC=co,DC=id";
         $dn = "OU=Users,OU=ho-bintaro,DC=thebodyshop,DC=co,DC=id";
         $filter = "(|(SN=*)(CN=*))";
         $sr = ldap_search($ds, $dn, $filter);
         $info = ldap_get_entries($ds, $sr);
         $dn = "OU=user,OU=warehouse-bsd,DC=thebodyshop,DC=co,DC=id";
         $filter = "(|(SN=*)(CN=*))";
         $sr = ldap_search($ds, $dn, $filter);
         $infoDc = ldap_get_entries($ds, $sr);
         $this->parseUsers($info, $infoDc);
         ldap_close($ds);
     } else {
         echo "Unable to connect to LDAP server";
     }
 }
开发者ID:CapsuleCorpIndonesia,项目名称:es-teler-baru-suka,代码行数:29,代码来源:Ldap.php

示例4: search

 function search($uname, &$u)
 {
     $utimer = utime();
     $filter = '(sAMAccountName=' . $uname . ')';
     if ($result = ldap_search($this->c, LDAPTREE, $filter)) {
         $data = ldap_get_entries($this->c, $result);
         $keys = array_keys($data[0]);
         $member = '';
         while (list($k, $v) = each($keys)) {
             //  echo "<!-- [$v] -->\n";
             if (isset($u->{$v})) {
                 if ($v == 'memberof') {
                     for ($i = 0; $i < $data[0][$v]['count']; $i++) {
                         $member .= $data[0][$v][$i] . ';';
                     }
                     $u->{$v} = $member;
                 } else {
                     $u->{$v} = $data[0][$v]['0'];
                 }
             }
             // debug - et mis meil üldse AD'st saada on
             //  $uu = $data['0'][$v]['0'];
             //  echo "<!-- $v = $uu -->\n";
         }
         if ($this->debug) {
             $t = stop_utimer($utimer);
             $this->m[] = "<!-- LDAP [{$t}] userdata for [{$uname}] -->\n";
         }
         return true;
     }
     return false;
 }
开发者ID:jotttt,项目名称:auth,代码行数:32,代码来源:class_ldap.php

示例5: __construct

 public function __construct($userKey)
 {
     $config = new Configuration();
     //try to connect to ldap if the settings are entered
     if ($config->ldap->host) {
         //If you are using OpenLDAP 2.x.x you can specify a URL instead of the hostname. To use LDAP with SSL, compile OpenLDAP 2.x.x with SSL support, configure PHP with SSL, and set this parameter as ldaps://hostname/.
         //note that connect happens regardless if host is valid
         $ds = ldap_connect($config->ldap->host);
         //may need ldap_bind( $ds, $username, $password )
         $bd = ldap_bind($ds) or die("<br /><h3>" . _("Could not connect to ") . $config->ldap->host . "</h3>");
         if ($bd) {
             $filter = $config->ldap->search_key . "=" . $userKey;
             $sr = ldap_search($ds, $config->ldap->base_dn, $filter);
             if ($entries = ldap_get_entries($ds, $sr)) {
                 $entry = $entries[0];
                 $fieldNames = array('fname', 'lname', 'email', 'phone', 'department', 'title', 'address');
                 foreach ($fieldNames as $fieldName) {
                     $configName = $fieldName . '_field';
                     $this->{$fieldName} = $entry[$config->ldap->{$configName}][0];
                 }
                 $this->fullname = addslashes($this->fname . ' ' . $this->lname);
             }
             ldap_close($ds);
         }
     }
 }
开发者ID:billdueber,项目名称:resources,代码行数:26,代码来源:LdapPerson.php

示例6: computer_list

function computer_list()
{
    $userid = new user($_GET["userid"]);
    $dn = $userid->dn;
    $ldap = new clladp();
    $pattern = "(&(objectClass=ComputerAfectation)(cn=*))";
    $attr = array();
    $sr = @ldap_search($ldap->ldap_connection, $dn, $pattern, $attr);
    if (!$sr) {
        return null;
    }
    $hash = ldap_get_entries($ldap->ldap_connection, $sr);
    if ($hash["count"] == 0) {
        return;
    }
    for ($i = 0; $i < $hash["count"]; $i++) {
        $uid = $hash[$i]["uid"][0];
        $mac = $hash[$i]["computermacaddress"][0];
        $computer = new computers($uid);
        $uid_text = str_replace("\$", "", $uid);
        $js = "javascript:Loadjs('computer.infos.php?uid={$uid}');";
        $tb[] = "<div style='float:left;margin:3px'>" . Paragraphe("64-computer.png", $uid_text, "<strong>{$mac}<div><i>{$computer->ComputerOS}</i></div><div>{$computer->ComputerIP}</div></strong>", $js) . "</div>";
    }
    $html = "<div style='width:100%'>" . implode("\n", $tb);
    $tpl = new templates();
    echo $tpl->_ENGINE_parse_body($html);
}
开发者ID:brucewu16899,项目名称:artica,代码行数:27,代码来源:domains.user.computer.php

示例7: getObject

 public function getObject($identity)
 {
     $connection = $this->bindToLdap();
     if ($resultSet = ldap_search($connection, $this->searchBase, "(&(cn={$identity})(objectClass=jsonObject))")) {
         if ($results = ldap_get_entries($connection, $resultSet)) {
             if ($results['count'] > 0) {
                 $tmp = json_decode($results[0]['jsonstring'][0], true);
                 if (is_array($tmp)) {
                     $value = $tmp;
                     $value['id'] = $results[0]['cn'][0];
                     $value['expire'] = intval($results[0]['expiretime'][0]);
                 }
             }
         } else {
             $error = 'failed to retrieve search result';
         }
     } else {
         $error = 'failed to execute search';
     }
     ldap_close($connection);
     if (isset($error)) {
         throw new Exception($error);
     } else {
         if (isset($value) && $value['expire'] > time()) {
             return $value;
         } else {
             return null;
         }
     }
 }
开发者ID:shamus13,项目名称:simplesamlphp-module-oauth2server,代码行数:30,代码来源:LDAPStore.php

示例8: auth

 /**
  * Conecta ao servidor LDAP com o usuário e senha configurado e depois verifica
  * se existe o usuário e senha informados por parâmetro.
  *
  * @param type $username
  * @param type $password
  *
  * @throws \Exception
  *
  * @return bool
  */
 public function auth($username, $password)
 {
     if ($this->host) {
         $message = _('Não foi possível conectar ao servidor LDAP. Favor verificar se as configurações estão corretas.');
         list($conn, $bind) = $this->connect($this->username, $this->password);
         if ($conn && $bind) {
             if (!empty($this->filter)) {
                 $filter = $this->filter[0] != '(' ? '(' . $this->filter . ')' : $this->filter;
                 $filter = sprintf('(&%s(%s=%s))', $filter, $this->loginAttribute, $username);
             } else {
                 $filter = sprintf('(%s=%s)', $this->loginAttribute, $username);
             }
             $search = @ldap_search($conn, $this->baseDn, $filter);
             if ($search) {
                 $result = @ldap_get_entries($conn, $search);
                 if ($result && $result['count'] == 1) {
                     $user = $result[0];
                     $bind = @ldap_bind($conn, $user['dn'], $password);
                     if ($bind) {
                         return $this->createUser($username, $user);
                     }
                 }
             } else {
                 throw new \Exception($message);
             }
         } else {
             throw new \Exception($message);
         }
     }
     return parent::auth($username, $password);
 }
开发者ID:alnetosilva,项目名称:novosga,代码行数:42,代码来源:LdapProvider.php

示例9: AD_Login

function AD_Login($user, $password, &$userdata)
{
    global $SYS;
    $adServer = $SYS["AUTH"]["activedirectory"]["server"];
    $basedn = $SYS["AUTH"]["activedirectory"]["basedn"];
    $searchuserdn = $SYS["AUTH"]["activedirectory"]["searchdn"];
    $domain = $SYS["AUTH"]["activedirectory"]["domain"];
    $ldapconn = ldap_connect($adServer);
    if (!$ldapconn) {
        return false;
    }
    $ldapbind = ldap_bind($ldapconn, "{$user}@{$domain}", $password);
    if ($ldapbind) {
        // We're inside!!
        $filter = "CN={$user}";
        foreach ($SYS["AUTH"]["activedirectory"]["searchdn"] as $v) {
            $sr = ldap_search($ldapconn, " {$v},{$basedn}", $filter);
            if ($sr) {
                $info = ldap_get_entries($ldapconn, $sr);
                if ($info["count"] > 0) {
                    $userdata["username"] = $info[0]["cn"][0];
                    $guessNameArr1 = explode("-", $info[0]["displayname"][0]);
                    $guessNameArr = explode(" ", trim($guessNameArr1[0]));
                    $userdata["apellidos"] = $guessNameArr[sizeof($guessNameArr) - 2] . " " . $guessNameArr[sizeof($guessNameArr) - 1];
                    $nombreArr = array_shift(array_reverse($guessNameArr));
                    $userdata["nombre"] = str_replace($userdata["apellidos"], "", trim($guessNameArr1[0]));
                    $userdata["email"] = $info[0]["mail"][0];
                    return true;
                }
            }
        }
    }
    return false;
}
开发者ID:BackupTheBerlios,项目名称:ascore,代码行数:34,代码来源:active_directory.php

示例10: autmount_list

function autmount_list()
{
    $samba = new samba();
    $ldap = new clladp();
    $dn = "ou=auto.automounts,ou=mounts,{$ldap->suffix}";
    $filter = "(&(ObjectClass=automount)(automountInformation=*))";
    $attrs = array("automountInformation", "cn");
    $html = "<table style='width:99%'>";
    $sr = @ldap_search($ldap->ldap_connection, $dn, $filter, $attrs);
    if ($sr) {
        $hash = ldap_get_entries($ldap->ldap_connection, $sr);
        if ($hash["count"] > 0) {
            for ($i = 0; $i < $hash["count"]; $i++) {
                $path = $hash[$i]["cn"][0];
                $automountInformation = $hash[$i][strtolower("automountInformation")][0];
                $js = "ShareDevice('{$path}');";
                $delete = "&nbsp;";
                if (is_array($samba->main_array[$path])) {
                    $delete = imgtootltip('ed_delete.gif', '{delete}', "DeleteUsbShare('{$path}')");
                    $js = "FolderProp('{$path}')";
                }
                $html = $html . "\n\t\t\t\t\t<tr " . CellRollOver($js) . ">\n\t\t\t\t\t\t<td width=1%><img src='img/fw_bold.gif'></td>\n\t\t\t\t\t\t<td colspan=2 ><code style='font-size:13px;font-weight:bold'>{$path}</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>&nbsp;</td>\n\t\t\t\t\t\t<td ><code style='font-size:1Opx;font-weight:bold'>{$automountInformation}</td>\n\t\t\t\t\t\t<td width=1%>{$delete}</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr><td colspan=3><hr></td></tr>\t";
            }
        }
    }
    $html = $html . "</table>";
    $tpl = new templates();
    return $tpl->_ENGINE_parse_body($html);
}
开发者ID:brucewu16899,项目名称:artica,代码行数:29,代码来源:samba.usb.php

示例11: findDN

function findDN($id, $password)
{
    // Finds the user's Distinguished Name - the key that uniquely identifies each entry in the directory
    global $ldap_host;
    // Connects to the LDAP server
    $ds = ldap_connect($ldap_host) or die("LDAP connection failed. Please see installation notes on how to configure Apache to work with LDAP.");
    if ($ds) {
        // Connection was successful
        // Performs anonymous bind to LDAP server
        $r = ldap_bind($ds);
        if ($r) {
            // Binding to LDAP server was unsuccessful
            // Determines whether the username provided is the uidNumber (which is numeric - 499908), or the uniqueID (which is alphanumeric - cam01329)
            $filterString = is_numeric($id) ? "uidNumber={$id}" : "uniqueID={$id}";
            // Performs search for the LDAP number
            $searchResult = ldap_search($ds, "ou=LAN,o=PORT", $filterString);
            // Gets entries for this search
            $info = ldap_get_entries($ds, $searchResult);
            // Retrieves the DN and givenname (e.g. Alasdair) for the user
            $dn = $info[0]["dn"];
            $givenname = $info[0]['givenname'][0];
            // Calls the authenticate function
            authenticate($dn, $password, $givenname);
        } else {
            // Binding to LDAP server was unsuccessful
            echo "Unable to connect to LDAP server";
            echo "<p>Click <a href='../../login.php'>here</a> to go back.</p>";
        }
    } else {
        // Connection to LDAP server was unsuccessful
        echo "Unable to connect to LDAP server";
        echo "<p>Click <a href='../../login.php'>here</a> to go back.</p>";
    }
}
开发者ID:40thieves,项目名称:WikiVLE,代码行数:34,代码来源:ldapLogin.php

示例12: updateProfile

 public static function updateProfile($numero_membre, $data)
 {
     $handle_ldap = self::initialize();
     if (self::$isDisabled) {
         self::$logger->info("Ldap is disabled, doing nothing.");
         return false;
     }
     $membreExists = @ldap_search($handle_ldap, "cn={$numero_membre}, " . self::$conf['basedn'], "objectclass=*", array("cn", "description", "mail"));
     if ($membreExists) {
         $personnes = ldap_get_entries($handle_ldap, $membreExists);
         $personne = $personnes[0];
         $dn = $personne["dn"];
         //self::$logger->debug(print_r($personne, true));
         $newEmail = self::$conf['defaultEmail'];
         if (isset($data['email']) && $data['email']) {
             $newEmail = $data['email'];
         }
         $hasLdapEmail = @is_array($personne["mail"]);
         $ldapData = ['mail' => [$newEmail]];
         if ($hasLdapEmail) {
             self::$logger->info("Replacing ldap email for #{$numero_membre}: {$newEmail}");
             ldap_mod_replace($handle_ldap, $dn, $ldapData);
         } else {
             self::$logger->info("Adding ldap email for #{$numero_membre}: {$newEmail}");
             ldap_mod_add($handle_ldap, $dn, $ldapData);
         }
         $err = ldap_error($handle_ldap);
         if ($err != "Success") {
             return $err;
         }
     } else {
         return "Membre not found in ldap repo: #{$numero_membre}";
     }
 }
开发者ID:RomainBenetiere,项目名称:mon-compte,代码行数:34,代码来源:LdapSync.php

示例13: hook_post_auth_update_zonep_config

function hook_post_auth_update_zonep_config($login = null, $password = null) {
    global $ad_server, $ad_base_dn, $ad_bind_dn, $ad_bind_pw;
    global $ldap_server, $ldap_base_dn, $adminRdn, $adminPw, $se3Ip;

    // Check arguments
    if(!is_string($login) or !is_string($password))
	return false;

    // Ensure we have an ActiveDirectory server or LDAP server to contact
    if (empty($ad_server) && empty($ldap_server))
	return false;
	
	// Connect to AD or LDAP
	if (!empty($ad_server))    
		$ds = ldap_connect($ad_server);
	else
		$ds = ldap_connect($ldap_server);	

    if(!$ds)
	return false;
	
    // admin Bind on AD or LDAP
	if (!empty($ad_server))    
    	$r = ldap_bind($ds, $ad_bind_dn, $ad_bind_pw);
    else
    	$r = ldap_bind($ds, $adminRddn.$ldap_base_dn, $adminPw);    

    if(!$r)
	return false;

    // Fetch UNC from Active Directory
    $attributes = array('homeDirectory');

	if (!empty($ad_server))
    	$sr = ldap_search($ds, $ad_base_dn, "(sAMAccountName=$login)", $attributes);
    else 	
    	$sr = ldap_search($ds, $ldap_base_dn, "(uid=$login)", $attributes);

    if (! $sr)
	return false;

    $entries = ldap_get_entries($ds, $sr);

    if(empty($entries[0]['homedirectory'][0]))
	return false;

    if (!empty($ad_server))
    	$smb_share = str_replace('\\', '/', $entries[0]['homedirectory'][0]);
    else
    	$smb_share = "//$se3Ip/$login";

    // Call sudo wrapper to create autofs configuration file
    $handle = popen('sudo lcs-zonep-update-credentials', 'w');
    fwrite($handle, "$login\n$password\n$smb_share\n");
    $status = pclose($handle) >> 8;
    if ($status != 0)
	return false;

    return true;
}
开发者ID:rhertzog,项目名称:lcs,代码行数:60,代码来源:update_zonep_config.php

示例14: Logon

 function Logon($user, $domain, $pass)
 {
     debugLog('Wiper::Logon: ' . $user . '/' . $pass);
     if ($user == "") {
         debugLog('Wiper::Logon: No user name.');
     }
     if ($pass == "") {
         debugLog('Wiper::Logon: No password.');
     }
     $link_id = ldap_connect(LDAP_SERVER, 389);
     if (!$link_id) {
         debugLog('Wiper::Logon: Cannot connect LDAP server.');
     }
     if (!ldap_set_option($link_id, LDAP_OPT_PROTOCOL_VERSION, 3)) {
         debugLog('Wiper::Logon: Failed to set v3 protocol.');
     }
     $dn = LDAP_DOMAIN;
     $filter = "(&(objectclass=person)(userPassword=*)(|(uid={$user})(cn={$user})) )";
     $attributes = array('cn', 'userpassword', 'uid');
     $search = ldap_search($link_id, $dn, $filter, $attributes);
     $info = ldap_get_entries($link_id, $search);
     if ($info['count'] == 0) {
         debugLog("Wiper::Logon: No such ID: {$user}");
         return false;
     }
     if (!ldap_bind($link_id, $info[0]['dn'], $pass)) {
         debugLog("Wiper::Logon: Invalid Password: {$user}");
         return false;
     }
     return true;
 }
开发者ID:updoor,项目名称:iRemoteWipe,代码行数:31,代码来源:wiper.php

示例15: authenticate

function authenticate($username, $password)
{
    global $error;
    sleep(1);
    $server = "ldap.rit.edu";
    //RIT LDAP Server
    $basedn = "ou=people,dc=rit,dc=edu";
    //Base DN
    $script = $_SERVER['SCRIPT_NAME'];
    $filter = "(uid={$username})";
    //$filter="(&(|(!(displayname=Administrator*))(!(displayname=Admin*)))(uid=$username))";    //define an appropriate ldap search filter to find your users, and filter out accounts such as administrator(administrator should be renamed anyway!).
    $dn = "uid={$username}, ";
    if (!($connect = ldap_connect($server))) {
        return 0;
    }
    ini_set("display_errors", "0");
    if (!($bind = ldap_bind($connect, "{$dn}" . $basedn, $password)) || empty($password)) {
        $error = "You either have a wrong username or wrong password";
        return 0;
    }
    ini_set("display_errors", "1");
    $sr = ldap_search($connect, $basedn, "{$filter}");
    $info = ldap_get_entries($connect, $sr);
    $_SESSION['accountUserName'] = $username;
    $_SESSION['accountFirstName'] = $info[0]['givenname'][0];
    $_SESSION['accountLastName'] = $info[0]['sn'][0];
    $_SESSION['accountPhone'] = $info[0]['telephonenumber'][0];
    $_SESSION['accountEmail'] = $info[0]['mail'][0];
    $_SESSION['accountType'] = $info[0]['riteduaccounttype'][0];
    return 1;
}
开发者ID:bjcpgd,项目名称:palserve,代码行数:31,代码来源:ldap.php


注:本文中的ldap_get_entries函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。