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


PHP ldap_search函数代码示例

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


在下文中一共展示了ldap_search函数的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: login_ad

function login_ad($user_, $pass_, $tipo_)
{
    //Comienzo la conexión al servidor para tomar los datos de active directory
    $host = get_config('host');
    $puerto = get_config('puerto');
    $filter = "sAMAccountName=" . $user_ . "*";
    $attr = array("displayname", "mail", "givenname", "sn", "useraccountcontrol");
    $dn = get_config('dn');
    $conex = ldap_connect($host, $puerto) or die("No ha sido posible conectarse al servidor");
    if (!ldap_set_option($conex, LDAP_OPT_PROTOCOL_VERSION, 3)) {
        echo "<br>Failed to set protocol version to 3";
    }
    if ($conex) {
        $dominio = get_config("dominio");
        $r = @ldap_bind($conex, $user_ . $dominio, $pass_);
        $existe = get_perfil($user_, $tipo_);
        if ($r && count($existe) > 0) {
            //LOGIN CORRECTO
            $result = ldap_search($conex, $dn, $filter, $attr);
            $entries = ldap_get_entries($conex, $result);
            for ($i = 0; $i < $entries["count"]; $i++) {
                $nombre = fix_data(utf8_decode($entries[$i]["givenname"][0]));
                $apellidos = fix_data(utf8_decode($entries[$i]["sn"][0]));
                $email = fix_data($entries[$i]["mail"][0]);
                //Acutalizar información desde AD en la tabla de empleados
                $s_ = "update empleados set nombre='{$nombre}', apellidos='{$apellidos}', mail='{$email}' where id='{$existe['id']}'";
                $r_ = mysql_query($s_);
                session_name("loginUsuario");
                session_start();
                $_SESSION['NAME'] = $nombre . " " . $apellidos;
                $_SESSION['USER'] = $user_;
                $_SESSION['IDEMP'] = $existe['id'];
                $_SESSION['AUSENCIA'] = get_ausencia($existe['id']);
                $_SESSION['DEPTO'] = $existe['depto'];
                $_SESSION['TYPE'] = $tipo_;
            }
            switch ($tipo_) {
                case "administrador":
                    header("Location: admin/inicio.php");
                    break;
                case "capturista":
                    header("Location: capturista/inicio.php");
                    break;
                case "autorizador":
                    header("Location: autorizador/scrap_firmar.php");
                    break;
                case "reportes":
                    header("Location: reportes/rep_general.php?op=listado");
                    break;
            }
        } else {
            echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"0; URL=index.php?error=2&user_={$user_}&tipo_={$tipo_}\">";
            exit;
        }
        ldap_close($conex);
    } else {
        echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"0; URL=index.php?error=3&user_={$user_}&tipo_={$tipo_}\">";
        exit;
    }
}
开发者ID:BrutalAndSick,项目名称:scrap,代码行数:60,代码来源:index11111.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: get_ldap_members

function get_ldap_members($group, $user, $password)
{
    global $ldap_host;
    global $ldap_dn;
    $LDAPFieldsToFind = array("member");
    print "{$ldap_host} {$ldap_dn}\n";
    $ldap = ldap_connect($ldap_host) or die("Could not connect to LDAP");
    // OPTIONS TO AD
    ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
    ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0);
    ldap_bind($ldap, $user, $password) or die("Could not bind to LDAP");
    //check if group is just a name or an ldap string
    $group_cn = preg_match("/cn=/i", $group) ? $group : "cn={$group}";
    $results = ldap_search($ldap, $ldap_dn, $group_cn, $LDAPFieldsToFind);
    $member_list = ldap_get_entries($ldap, $results);
    $group_member_details = array();
    if (is_array($member_list[0])) {
        foreach ($member_list[0] as $list) {
            if (is_array($list)) {
                foreach ($list as $member) {
                    $member_dn = explode_dn($member);
                    $member_cn = str_replace("CN=", "", $member_dn[0]);
                    $member_search = ldap_search($ldap, $ldap_dn, "(CN=" . $member_cn . ")");
                    $member_details = ldap_get_entries($ldap, $member_search);
                    $group_member_details[] = array($member_details[0]['samaccountname'][0], $member_details[0]['displayname'][0], $member_details[0]['useraccountcontrol'][0]);
                }
            }
        }
    }
    ldap_close($ldap);
    array_shift($group_member_details);
    return $group_member_details;
    ldap_unbind($ldap);
}
开发者ID:LFCavalcanti,项目名称:pfsense-packages,代码行数:34,代码来源:dansguardian_ldap.php

示例7: ldap_auth

function ldap_auth()
{
    $ldap_server = 'ldap://127.0.0.1/';
    $ldap_domain = 'dc=rugion,dc=ru';
    //$ldap_userbase = 'ou=users,ou=chelyabinsk,' . $ldap_domain;
    //$ldap_user = 'uid=' . $_SERVER['PHP_AUTH_USER'] . ',' . $ldap_userbase;
    $ldap_user = ' ';
    $ldap_pass = $_SERVER['PHP_AUTH_PW'];
    $ldapconn_s = ldap_connect($ldap_server) or die("Could not connect to LDAP server.");
    ldap_set_option($ldapconn_s, LDAP_OPT_PROTOCOL_VERSION, 3);
    if ($ldapconn_s) {
        $ldapbind_s = @ldap_bind($ldapconn_s);
        $result = ldap_search($ldapconn_s, $ldap_domain, "(&(uid=" . $_SERVER['PHP_AUTH_USER'] . ")(objectClass=sambaSamAccount)(!(sambaAcctFlags=[DU ])))");
        $info = ldap_get_entries($ldapconn_s, $result);
        $ldap_user = $info[0]["dn"];
    }
    ldap_close($ldapconn_s);
    // connect to ldap server
    $ldapconn = ldap_connect($ldap_server) or die("Could not connect to LDAP server.");
    ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
    if ($ldapconn) {
        // try to bind/authenticate against ldap
        $ldapbind = @ldap_bind($ldapconn, $ldap_user, $ldap_pass) || forbidden();
        // "LDAP bind successful...";
        error_log("success: " . $_SERVER['REMOTE_ADDR'] . ', user: ' . $_SERVER['PHP_AUTH_USER']);
    }
    ldap_close($ldapconn);
}
开发者ID:le9i0nx,项目名称:ansible-root,代码行数:28,代码来源:ldap-auth.php

示例8: ajax_loadtags

/**
 * Load current tags of an entry
 */
function ajax_loadtags($dn, $type = 'plain')
{
    global $conf;
    global $LDAP_CON;
    global $FIELDS;
    if (!$FIELDS['_marker']) {
        return;
    }
    header('Content-Type: text/html; charset=utf-8');
    $sr = ldap_search($LDAP_CON, $dn, '(objectClass=inetOrgPerson)', array($FIELDS['_marker']));
    if (!ldap_count_entries($LDAP_CON, $sr)) {
        return false;
    }
    $result = ldap_get_binentries($LDAP_CON, $sr);
    $entry = $result[0];
    if ($type == 'plain') {
        echo join(', ', (array) $entry[$FIELDS['_marker']]);
    } else {
        foreach ((array) $entry[$FIELDS['_marker']] as $tag) {
            echo '<a href="index.php?marker=';
            echo rawurlencode($tag);
            echo '" class="tag">';
            echo htmlspecialchars($tag);
            echo '</a> ';
        }
    }
}
开发者ID:pneff,项目名称:contagged,代码行数:30,代码来源:ajax.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: 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

示例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: 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

示例13: 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

示例14: 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

示例15: 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


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