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


PHP ldap_unbind函数代码示例

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


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

示例1: __destruct

 function __destruct()
 {
     // close the connection
     if ($this->ds) {
         ldap_unbind($this->ds);
     }
 }
开发者ID:Teino1978-Corp,项目名称:Teino1978-Corp-owncloud_.htaccess-,代码行数:7,代码来源:owncloud_apps_user_ldap_user_ldap.php

示例2: ParseLDAP

function ParseLDAP()
{
    $ldap = new cronldap();
    $today = date('Y-m-d');
    $connect = $ldap->ldap_connection;
    $_GET["suffix"] = $ldap->suffix;
    $pattern = "(&(objectClass=UserArticaClass)(FinalDateToLive=*)(!(FinalDateToLive=0)))";
    $attr = array("uid", "FinalDateToLive", "dn");
    $sr = ldap_search($connect, $_GET["suffix"], $pattern, $attr);
    if ($sr) {
        $hash = ldap_get_entries($connect, $sr);
        if ($hash["count"] > 0) {
            for ($i = 0; $i < $hash["count"]; $i++) {
                $uid = $hash[$i]["uid"][0];
                $dn = $hash[$i]["dn"];
                $FinalDateToLive = $hash[$i][strtolower("FinalDateToLive")][0];
                $diff = DateDiff($today, $FinalDateToLive);
                echo "Analyze {$dn}: {$uid} :{$FinalDateToLive} ({$diff} day(s))\n";
                if ($diff < 0) {
                    echo "This user must be deleted...\n";
                    delete_ldap($dn, $connect, true);
                    DeleteMBX($uid);
                }
            }
        }
    }
    @ldap_unbind($connect);
    unset($GLOBALS["LDAP_BIN_ID"]);
    unset($GLOBALS["LDAP_CONNECT_ID"]);
    echo "\n";
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:31,代码来源:cron.endoflife.php

示例3: is_prof

function is_prof($login)
{
    global $ldap_server, $ldap_port, $dn;
    global $error;
    $error = "";
    $filter = "(&(cn=profs*)(memberUid={$login}))";
    $ldap_groups_attr = array("cn", "memberUid");
    /*-----------------------------------------------------*/
    $ds = @ldap_connect($ldap_server, $ldap_port);
    if ($ds) {
        $r = @ldap_bind($ds);
        if (!$r) {
            $error = "Echec du bind anonyme";
        } else {
            // Recherche du groupe d'appartenance de l'utilisateur connecte
            $result = @ldap_list($ds, $dn["groups"], $filter, $ldap_groups_attr);
            if ($result) {
                $info = @ldap_get_entries($ds, $result);
                if ($info["count"]) {
                    $is_prof = true;
                } else {
                    $is_prof = false;
                }
            }
        }
    }
    @ldap_unbind($ds);
    @ldap_close($ds);
    return $is_prof;
}
开发者ID:rhertzog,项目名称:lcs,代码行数:30,代码来源:init_users_lcs.php

示例4: unBind

 /** 	
  * unbinds from the LDAP Server
  * @access public
  */
 function unBind()
 {
     if ($this->ldap_debug) {
         error_log(__FILE__ . " " . __METHOD__ . " " . __LINE__ . " Unbinding from LDAP Server " . $this->ldapconfig['host']);
     }
     ldap_unbind($this->ldapconn);
 }
开发者ID:chandradrupal,项目名称:resourcespace,代码行数:11,代码来源:ldap_class.php

示例5: generar_lista_grupos

function generar_lista_grupos()
{
    $user = $_SESSION['userblanco'];
    $ldappass = $_SESSION['pass'];
    $ldaprdn = "electrotecnica\\" . $user;
    $adServer = "pegasus.electrotecnica.local";
    #replace with your AD server ip/hostname
    $ldapconn = ldap_connect($adServer) or die("Couldn't connect to AD!");
    // Bind to the directory server.
    $ldapbind = ldap_bind($ldapconn, $ldaprdn, $ldappass) or die("Couldn't bind to AD!");
    $dn = 'OU=Electrotecnica,dc=electrotecnica,dc=local';
    //$filter = 'samaccountname='.$ldaprdn;
    $filter = '(samaccountname=' . $user . ')';
    $result = ldap_search($ldapconn, $dn, $filter);
    $entries = ldap_get_entries($ldapconn, $result);
    for ($i = 0; $i < $entries["count"]; $i++) {
        try {
            $groups = array();
            // Loop through the groups that the user is a `memberof`
            foreach ($entries[0]['memberof'] as $group) {
                // extract Group name from string
                $temp = substr($group, 0, stripos($group, ","));
                // Strip the CN= and change to lowercase for easy handling
                $temp = strtolower(str_replace("CN=", "", $temp));
                $groups[] .= $temp;
            }
        } catch (Exception $e) {
            echo 'error';
        }
    }
    // Close the connection
    ldap_unbind($ldapconn);
    return $groups;
}
开发者ID:neojoker,项目名称:blablabla,代码行数:34,代码来源:groups.php

示例6: unbind

 /**
  * 取消绑定,等同于关闭连接
  * 
  */
 public function unbind()
 {
     if ($this->link !== false) {
         ldap_unbind($this->link);
         $this->link = false;
     }
 }
开发者ID:ronalfei,项目名称:CodeAnt,代码行数:11,代码来源:ldap.class.php

示例7: update_dhcpmtime_old

function update_dhcpmtime_old($au_array)
{
    global $ds, $auDN, $ldapError, $dhcpman_pwd;
    $entry['dhcpmtime'] = time();
    # eigene AU
    $results = ldap_mod_replace($ds, $auDN, $entry);
    if ($results) {
        echo "<br><b>dhcpMTime</b> erfolgreich in AU " . $auDN . " aktualisiert!<br>";
        #return 1;
    } else {
        echo "<br>Fehler beim Aktualisieren der <b>dhcpMTime</b> in {$auDN}!<br>";
    }
    # andere AUs
    if (count($au_array) != 0) {
        $au_array = array_unique($au_array);
        # Bind als DHCP Manager
        $dhcp_uid = "dhcpmanager";
        if (!($dhcp_ds = uniLdapConnect($dhcp_uid, $dhcpman_pwd))) {
            echo "Konnte nicht als <b>DHCP-Manager</b> mit LDAP Server verbinden";
            die;
        } else {
            #echo "DHCP BIND erfolgreich";
            foreach ($au_array as $au) {
                $results = ldap_mod_replace($dhcp_ds, $au, $entry);
                if ($results) {
                    echo "<b>dhcpMTime</b> erfolgreich in AU " . $au . " aktualisiert!<br>";
                    #return 1;
                } else {
                    echo "<br>Fehler beim Aktualisieren der <b>dhcpMTime</b> in AU {$au}!<br>";
                }
            }
            ldap_unbind($dhcp_ds);
        }
    }
}
开发者ID:BackupTheBerlios,项目名称:openslx-svn,代码行数:35,代码来源:dhcp_management_functions.php

示例8: authenticate

 public static function authenticate($username, $password)
 {
     if (!config('cmauth.ldap')) {
         Session::flash('ldap_error', "ldap is not set for this application");
         return false;
     }
     if (empty($username) or empty($password)) {
         Session::flash('ldap_error', 'Error binding to LDAP: username or password empty');
         return false;
     }
     if (!($ldapconn = ldap_connect(config('cmauth.ldap_server'), config('cmauth.ldap_port')))) {
         Session::flash('ldap_error', "Could not connect to LDAP server.");
         return false;
     }
     $ldapRdn = config('cmauth.ldap_domain') . "\\" . $username;
     if ($ldapconn) {
         $ldapbind = @ldap_bind($ldapconn, $ldapRdn, $password);
         if ($ldapbind) {
             return true;
         } else {
             Session::flash('ldap_error', 'You have entered wrong username and password');
             return false;
         }
         ldap_unbind($ldapconn);
     } else {
         Session::flash('ldap_error', 'Error connecting to LDAP.');
         return false;
     }
     return false;
 }
开发者ID:cemleme,项目名称:cmauth,代码行数:30,代码来源:LDAP.php

示例9: close

 public function close()
 {
     if (is_resource($this->link)) {
         @ldap_unbind($this->link);
         $this->link = null;
     }
 }
开发者ID:dapepe,项目名称:tymio,代码行数:7,代码来源:ldap.php

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

示例11: ldap_login

function ldap_login($username, $password)
{
    $ldapServer = "ldap.iitm.ac.in";
    $ldapPort = 389;
    $ldapDn = "cn=students,ou=bind,dc=ldap,dc=iitm,dc=ac,dc=in";
    $ldapPass = "rE11Bg_oO~iC";
    $ldapConn = ldap_connect($ldapServer, $ldapPort) or die("Could not connect to LDAP server.");
    echo $ldapConn;
    $studentUser = $username;
    $studentPass = $password;
    if ($ldapConn) {
        $ldapBind = @ldap_bind($ldapConn, $ldapDn, $ldapPass);
        if ($ldapBind) {
            $filter = "(&(objectclass=*)(uid=" . $studentUser . "))";
            $ldapDn = "dc=ldap,dc=iitm,dc=ac,dc=in";
            $result = @ldap_search($ldapConn, $ldapDn, $filter) or die("Error in search query: " . ldap_error($ldapConn));
            $entries = @ldap_get_entries($ldapConn, $result);
            foreach ($entries as $values => $values1) {
                $logindn = $values1['dn'];
            }
            $loginbind = @ldap_bind($ldapConn, $logindn, $studentPass);
            if ($loginbind) {
                return 1;
            }
        }
    }
    @ldap_unbind($ldapConn);
    return 0;
}
开发者ID:ShashankSubramanian,项目名称:Dean-Blog,代码行数:29,代码来源:ldaplogin.php

示例12: __destruct

 /**
  * Unbinds the current University LDAP connection when the object is destroyed.
  */
 public function __destruct()
 {
     $this->log('Unbinding from University LDAP.');
     if (!ldap_unbind($this->connection)) {
         $this->trigger_ldap_error('Unable unbind from University LDAP.', E_USER_WARNING);
     }
 }
开发者ID:CIF-Rochester,项目名称:Panel,代码行数:10,代码来源:UniversityLdap.php

示例13: login

 function login($uid, $pwd, $ip = 0)
 {
     $this->groups = array();
     $this->uid = $uid;
     if (!($ds = ldap_connect($this->host))) {
         return false;
     }
     if (!($r = @ldap_bind($ds, "uid={$uid},{$this->basedn}", $pwd))) {
         ldap_unbind($ds);
         sess_log(LOG_LOGIN, 0, "uid={$uid},{$this->basedn}", 0);
         return false;
     }
     $filter = "(&(objectclass=posixGroup)(memberuid={$uid}))";
     $retvals = array("cn");
     $sr = ldap_search($ds, $this->basedn, $filter, $retvals);
     $entries = ldap_get_entries($ds, $sr);
     $this->groups = array();
     for ($i = 0; $i < $entries["count"]; $i++) {
         for ($j = 0; $j < $entries[$i]["cn"]["count"]; $j++) {
             $this->groups[] = $entries[$i]["cn"][$j];
         }
     }
     ldap_free_result($sr);
     ldap_unbind($ds);
     //	print_r( $this->groups );
     sess_log(LOG_LOGIN, 0, "uid={$uid},{$this->basedn}", 1);
     return true;
 }
开发者ID:BackupTheBerlios,项目名称:dilps,代码行数:28,代码来源:authLDAP2307User.class.php

示例14: disconnect

 public function disconnect()
 {
     if ($ldapConnection) {
         @ldap_unbind($ldapConnection);
         //Assume success
     }
     $ldapConnection = null;
 }
开发者ID:nyaray,项目名称:tekweb,代码行数:8,代码来源:lib_ldap.php

示例15: is_correct_password

 /**
  * @see IdentityProvider_Driver::is_correct_password.
  */
 public function is_correct_password($user, $password)
 {
     $connection = ldap_connect(self::$_params["url"]);
     ldap_set_option($connection, LDAP_OPT_PROTOCOL_VERSION, 3);
     $lbind = @ldap_bind($connection, $user->dn, $password);
     ldap_unbind($connection);
     return $lbind ? true : false;
 }
开发者ID:ChrisRut,项目名称:gallery3-contrib,代码行数:11,代码来源:Ldap.php


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