本文整理汇总了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";
}
示例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;
}
示例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);
}
示例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;
}
示例6: unbind
/**
* 取消绑定,等同于关闭连接
*
*/
public function unbind()
{
if ($this->link !== false) {
ldap_unbind($this->link);
$this->link = false;
}
}
示例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);
}
}
}
示例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;
}
示例9: close
public function close()
{
if (is_resource($this->link)) {
@ldap_unbind($this->link);
$this->link = null;
}
}
示例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);
}
示例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;
}
示例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);
}
}
示例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;
}
示例14: disconnect
public function disconnect()
{
if ($ldapConnection) {
@ldap_unbind($ldapConnection);
//Assume success
}
$ldapConnection = null;
}
示例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;
}