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


PHP adLDAP::getLdapBind方法代码示例

本文整理汇总了PHP中adLDAP::getLdapBind方法的典型用法代码示例。如果您正苦于以下问题:PHP adLDAP::getLdapBind方法的具体用法?PHP adLDAP::getLdapBind怎么用?PHP adLDAP::getLdapBind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在adLDAP的用法示例。


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

示例1: all

 /**
  * Return a list of all contacts
  * 
  * @param bool $includeDescription Include a description of a contact
  * @param string $search The search parameters
  * @param bool $sorted Whether to sort the results
  * @return array
  */
 public function all($includeDescription = false, $search = "*", $sorted = true)
 {
     if (!$this->adldap->getLdapBind()) {
         return false;
     }
     // Perform the search and grab all their details
     $filter = "(&(objectClass=contact)(cn=" . $search . "))";
     $fields = array("displayname", "distinguishedname");
     $sr = ldap_search($this->adldap->getLdapConnection(), $this->adldap->getBaseDn(), $filter, $fields);
     $entries = ldap_get_entries($this->adldap->getLdapConnection(), $sr);
     $usersArray = array();
     for ($i = 0; $i < $entries["count"]; $i++) {
         if ($includeDescription && strlen($entries[$i]["displayname"][0]) > 0) {
             $usersArray[$entries[$i]["distinguishedname"][0]] = $entries[$i]["displayname"][0];
         } elseif ($include_desc) {
             $usersArray[$entries[$i]["distinguishedname"][0]] = $entries[$i]["distinguishedname"][0];
         } else {
             array_push($usersArray, $entries[$i]["distinguishedname"][0]);
         }
     }
     if ($sorted) {
         asort($usersArray);
     }
     return $usersArray;
 }
开发者ID:kinhvan017,项目名称:phpipam,代码行数:33,代码来源:adLDAPContacts.php

示例2: search

 /**
  * Returns a complete list of the groups in AD based on a SAM Account Type  
  * 
  * @param string $sAMAaccountType The account type to return
  * @param bool $includeDescription Whether to return a description
  * @param string $search Search parameters
  * @param bool $sorted Whether to sort the results
  * @return array
  */
 public function search($sAMAaccountType = adLDAP::ADLDAP_SECURITY_GLOBAL_GROUP, $includeDescription = false, $search = "*", $sorted = true)
 {
     if (!$this->adldap->getLdapBind()) {
         return false;
     }
     $filter = '(&(objectCategory=group)';
     if ($sAMAaccountType !== null) {
         $filter .= '(samaccounttype=' . $sAMAaccountType . ')';
     }
     $filter .= '(cn=' . $search . '))';
     // Perform the search and grab all their details
     $fields = array("samaccountname", "description");
     $sr = ldap_search($this->adldap->getLdapConnection(), $this->adldap->getBaseDn(), $filter, $fields);
     $entries = ldap_get_entries($this->adldap->getLdapConnection(), $sr);
     $groupsArray = array();
     for ($i = 0; $i < $entries["count"]; $i++) {
         if ($includeDescription && strlen($entries[$i]["description"][0]) > 0) {
             $groupsArray[$entries[$i]["samaccountname"][0]] = $entries[$i]["description"][0];
         } else {
             if ($includeDescription) {
                 $groupsArray[$entries[$i]["samaccountname"][0]] = $entries[$i]["samaccountname"][0];
             } else {
                 array_push($groupsArray, $entries[$i]["samaccountname"][0]);
             }
         }
     }
     if ($sorted) {
         asort($groupsArray);
     }
     return $groupsArray;
 }
开发者ID:articatech,项目名称:artica,代码行数:40,代码来源:adLDAPGroups.php

示例3: move

 /**
  * Move a user account to a different OU
  *
  * @param string $username The username to move (please be careful here!)
  * @param array $container The container or containers to move the user to (please be careful here!).
  * accepts containers in 1. parent 2. child order
  * @return array
  */
 public function move($username, $container)
 {
     if (!$this->adldap->getLdapBind()) {
         return false;
     }
     if ($username === null) {
         return "Missing compulsory field [username]";
     }
     if ($container === null) {
         return "Missing compulsory field [container]";
     }
     if (!is_array($container)) {
         return "Container must be an array";
     }
     $userInfo = $this->info($username, array("*"));
     $dn = $userInfo[0]['distinguishedname'][0];
     $newRDn = "cn=" . $username;
     $container = array_reverse($container);
     $newContainer = "ou=" . implode(",ou=", $container);
     $newBaseDn = strtolower($newContainer) . "," . $this->adldap->getBaseDn();
     $result = @ldap_rename($this->adldap->getLdapConnection(), $dn, $newRDn, $newBaseDn, true);
     if ($result !== true) {
         return false;
     }
     return true;
 }
开发者ID:name256,项目名称:crm42,代码行数:34,代码来源:adLDAPUsers.php

示例4: getLastLogon

 /**
  * Get the last logon time of any user as a Unix timestamp
  * 
  * @param string $username
  * @return long $unixTimestamp
  */
 public function getLastLogon($username)
 {
     if (!$this->adldap->getLdapBind()) {
         return false;
     }
     if ($username === null) {
         return "Missing compulsory field [username]";
     }
     $userInfo = $this->info($username, array("lastLogonTimestamp"));
     $lastLogon = adLDAPUtils::convertWindowsTimeToUnixTime($userInfo[0]['lastLogonTimestamp'][0]);
     return $lastLogon;
 }
开发者ID:wernerflamme,项目名称:dokuwiki,代码行数:18,代码来源:adLDAPUsers.php

示例5: storageDatabases

 /**
  * Returns a list of Databases within any given storage group in Exchange for a given mail server
  * 
  * @param string $storageGroup The full DN of an Storage Group.  You can use exchange_storage_groups() to find the DN 
  * @param array $attributes An array of the AD attributes you wish to return
  * @return array
  */
 public function storageDatabases($storageGroup, $attributes = array('cn', 'distinguishedname', 'displayname'))
 {
     if (!$this->adldap->getLdapBind()) {
         return false;
     }
     if ($storageGroup === NULL) {
         return "Missing compulsory field [storageGroup]";
     }
     $filter = '(&(objectCategory=msExchPrivateMDB))';
     $sr = @ldap_search($this->adldap->getLdapConnection(), $storageGroup, $filter, $attributes);
     $entries = @ldap_get_entries($this->adldap->getLdapConnection(), $sr);
     return $entries;
 }
开发者ID:kidaa,项目名称:time-slot,代码行数:20,代码来源:adLDAPExchange.php

示例6: groups

 /**
  * Get the groups a computer is in
  * 
  * @param string $computerName The name of the computer
  * @param bool $recursive Whether to check recursively
  * @return array
  */
 public function groups($computerName, $recursive = NULL)
 {
     if ($computerName === NULL) {
         return false;
     }
     if ($recursive === NULL) {
         $recursive = $this->adldap->getRecursiveGroups();
     }
     //use the default option if they haven't set it
     if (!$this->adldap->getLdapBind()) {
         return false;
     }
     //search the directory for their information
     $info = @$this->info($computerName, array("memberof", "primarygroupid"));
     $groups = $this->adldap->utilities()->niceNames($info[0]["memberof"]);
     //presuming the entry returned is our guy (unique usernames)
     if ($recursive === true) {
         foreach ($groups as $id => $groupName) {
             $extraGroups = $this->adldap->group()->recursiveGroups($groupName);
             $groups = array_merge($groups, $extraGroups);
         }
     }
     return $groups;
 }
开发者ID:kidaa,项目名称:time-slot,代码行数:31,代码来源:adLDAPComputers.php

示例7: listing

 /**
  * Returns a folder listing for a specific OU
  * See http://adldap.sourceforge.net/wiki/doku.php?id=api_folder_functions
  *
  * @param array $folderName An array to the OU you wish to list.
  *                           If set to NULL will list the root, strongly recommended to set
  *                           $recursive to false in that instance!
  * @param string $dnType The type of record to list.  This can be ADLDAP_FOLDER or ADLDAP_CONTAINER.
  * @param bool $recursive Recursively search sub folders
  * @param bool $type Specify a type of object to search for
  * @return array
  */
 public function listing($folderName = NULL, $dnType = adLDAP::ADLDAP_FOLDER, $recursive = NULL, $type = NULL)
 {
     if ($recursive === NULL) {
         $recursive = $this->adldap->getRecursiveGroups();
     }
     //use the default option if they haven't set it
     if (!$this->adldap->getLdapBind()) {
         return false;
     }
     $filter = '(&';
     if ($type !== NULL) {
         switch ($type) {
             case 'contact':
                 $filter .= '(objectClass=contact)';
                 break;
             case 'computer':
                 $filter .= '(objectClass=computer)';
                 break;
             case 'group':
                 $filter .= '(objectClass=group)';
                 break;
             case 'folder':
                 $filter .= '(objectClass=organizationalUnit)';
                 break;
             case 'container':
                 $filter .= '(objectClass=container)';
                 break;
             case 'domain':
                 $filter .= '(objectClass=builtinDomain)';
                 break;
             default:
                 $filter .= '(objectClass=user)';
                 break;
         }
     } else {
         $filter .= '(objectClass=*)';
     }
     // If the folder name is null then we will search the root level of AD
     // This requires us to not have an OU= part, just the base_dn
     $searchOu = $this->adldap->getBaseDn();
     if (is_array($folderName)) {
         $ou = $dnType . "=" . implode("," . $dnType . "=", $folderName);
         $filter .= '(!(distinguishedname=' . $ou . ',' . $this->adldap->getBaseDn() . ')))';
         $searchOu = $ou . ',' . $this->adldap->getBaseDn();
     } else {
         $filter .= '(!(distinguishedname=' . $this->adldap->getBaseDn() . ')))';
     }
     if ($recursive === true) {
         $sr = ldap_search($this->adldap->getLdapConnection(), $searchOu, $filter, array('objectclass', 'distinguishedname', 'samaccountname'));
         $entries = @ldap_get_entries($this->adldap->getLdapConnection(), $sr);
         if (is_array($entries)) {
             return $entries;
         }
     } else {
         $sr = ldap_list($this->adldap->getLdapConnection(), $searchOu, $filter, array('objectclass', 'distinguishedname', 'samaccountname'));
         $entries = @ldap_get_entries($this->adldap->getLdapConnection(), $sr);
         if (is_array($entries)) {
             return $entries;
         }
     }
     return false;
 }
开发者ID:jotttt,项目名称:ttu-wiki,代码行数:74,代码来源:adLDAPFolders.php


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