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


PHP ldap_explode_dn函数代码示例

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


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

示例1: validateUsingLdapExt

 protected function validateUsingLdapExt($value)
 {
     if (!ldap_explode_dn($value, 0)) {
         return false;
     }
     return true;
 }
开发者ID:hovenko,项目名称:Madcow,代码行数:7,代码来源:LdapDN.php

示例2: getParentDN

 /**
  * @return string
  */
 public function getParentDN()
 {
     $parts = ldap_explode_dn($this->distinguisedName, 0);
     unset($parts['count']);
     unset($parts[0]);
     return implode(',', $parts);
 }
开发者ID:heiglandreas,项目名称:ldap,代码行数:10,代码来源:Object.php

示例3: createOrganizationalUnit

 /**
  * @param string $dn
  * @param bool   $createParent
  *
  * @return bool
  */
 public function createOrganizationalUnit($dn, $createParent = false)
 {
     $parts = ldap_explode_dn($dn, 0);
     unset($parts['count']);
     // Doesn't support anything else than 'ou'
     if (stripos($parts[0], 'ou=') !== 0) {
         return false;
     }
     // Previously create parents
     if ($createParent) {
         $parentParts = $parts;
         unset($parentParts[0]);
         $parent = implode(',', $parentParts);
         $found = $this->searchDN($parent);
         if (!$found) {
             $this->createOrganizationalUnit($parent, true);
         }
     }
     // Already exists ?
     $found = $this->searchDN($dn);
     if (!$found) {
         list(, $name) = explode('=', $parts[0]);
         $object = new Object($dn);
         $object->get('objectClass')->add('top');
         $object->get('objectClass')->add('organizationalUnit');
         $object->get('ou')->add($name);
         return $this->add($object, false);
     }
     return true;
 }
开发者ID:smalot,项目名称:ldap,代码行数:36,代码来源:Repository.php

示例4: explodeDN

 /**
  * Extends PHPs ldap_explode_dn() function
  *
  * UTF-8 chars like German umlauts would otherwise be escaped and shown
  * as backslash-prefixed hexcode-sequenzes.
  *
  * @param  string  DN
  * @param  boolean Returns 'type=value' when true and 'value' when false
  * @return string
  */
 public static function explodeDN($dn, $with_type = true)
 {
     $res = ldap_explode_dn($dn, $with_type ? 0 : 1);
     foreach ($res as $k => $v) {
         $res[$k] = preg_replace('/\\\\([0-9a-f]{2})/ei', "chr(hexdec('\\1'))", $v);
     }
     unset($res['count']);
     return $res;
 }
开发者ID:vbereza,项目名称:icinga2-migration,代码行数:19,代码来源:LdapUtils.php

示例5: explodeDn

 /**
  * Converts a string distinguished name into its separate pieces.
  *
  * @param string $dn
  * @param int $withAttributes Set to 0 to get the attribute names along with the value.
  * @return array
  */
 public static function explodeDn($dn, $withAttributes = 1)
 {
     $pieces = ldap_explode_dn($dn, $withAttributes);
     if ($pieces === false || !isset($pieces['count']) || $pieces['count'] == 0) {
         throw new \yii\base\InvalidParamException(sprintf('Unable to parse DN "%s".', $dn));
     }
     unset($pieces['count']);
     return $pieces;
 }
开发者ID:chrmorandi,项目名称:yii2-ldap,代码行数:16,代码来源:LdapUtils.php

示例6: explodeDn

 /**
  * Converts a DN string into an array of RDNs.
  *
  * This will also decode hex characters into their true
  * UTF-8 representation embedded inside the DN as well.
  *
  * @param string $dn
  * @param bool   $removeAttributePrefixes
  *
  * @return array|false
  */
 public static function explodeDn($dn, $removeAttributePrefixes = true)
 {
     $dn = ldap_explode_dn($dn, $removeAttributePrefixes ? 1 : 0);
     if (is_array($dn) && array_key_exists('count', $dn)) {
         foreach ($dn as $rdn => $value) {
             $dn[$rdn] = self::unescape($value);
         }
     }
     return $dn;
 }
开发者ID:adldap2,项目名称:adldap2,代码行数:21,代码来源:Utilities.php

示例7: explode_dn

function explode_dn($dn, $with_attributes = 0)
{
    $result = ldap_explode_dn($dn, $with_attributes);
    if (is_array($result)) {
        foreach ($result as $key => $value) {
            $result[$key] = $value;
        }
    }
    return $result;
}
开发者ID:LFCavalcanti,项目名称:pfsense-packages,代码行数:10,代码来源:dansguardian_ldap.php

示例8: __construct

 /**
  * Entry constructor.
  *
  * @param resource $ds
  *   LDAP connection resource.
  * @param string $rdn
  *   Relative distinguished name (to baseDN).
  * @param string $dn
  *   Distinguished name.
  * @param array $data
  *   Associative array of attribute keys and values.
  */
 public function __construct($ds, $rdn, $dn, $data)
 {
     $this->ds = $ds;
     $this->rdn = $rdn;
     $this->dn = $dn;
     $this->data = $data;
     $this->oldData = $data;
     $exploded_dn = ldap_explode_dn($dn, 0);
     $top_dn = explode('=', $exploded_dn[0]);
     $this->dnAttribute = strtolower($top_dn[0]);
 }
开发者ID:grom358,项目名称:php-ldap,代码行数:23,代码来源:Entry.php

示例9: explodeDN

 /**
  * Extends PHPs ldap_explode_dn() function
  *
  * UTF-8 chars like German umlauts would otherwise be escaped and shown
  * as backslash-prefixed hexcode-sequenzes.
  *
  * @param  string  DN
  * @param  boolean Returns 'type=value' when true and 'value' when false
  * @return string
  */
 public static function explodeDN($dn, $with_type = true)
 {
     $res = ldap_explode_dn($dn, $with_type ? 0 : 1);
     foreach ($res as $k => $v) {
         $res[$k] = preg_replace_callback('/\\\\([0-9a-f]{2})/i', function ($m) {
             return chr(hexdec($m[1]));
         }, $v);
     }
     unset($res['count']);
     return $res;
 }
开发者ID:0svald,项目名称:icingaweb2,代码行数:21,代码来源:LdapUtils.php

示例10: escapeDN

function escapeDN($dn)
{
    $aDN = ldap_explode_dn($dn, false);
    unset($aDN['count']);
    foreach ($aDN as $key => $part) {
        $value = substr($part, strpos($part, '=') + 1);
        $escapedValue = strtr($value, array(',' => '\\2c', '=' => '\\3d', '+' => '\\2b', '<' => '\\3c', '>' => '\\3e', ';' => '\\3b', '\\' => '\\5c', '"' => '\\22', '#' => '\\23'));
        $part = str_replace($part, $value, $escapedValue);
    }
    $dn = implode(',', $aDN);
    return $dn;
}
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:12,代码来源:update.php

示例11: testEntryConstruct

 public function testEntryConstruct()
 {
     $returnedLdapEntries = ['count' => 3, 0 => [0 => 'distinguishedname', 'count' => 1, 'dn' => 'CN=Karen Berge,CN=admin,DC=corp,DC=Fabrikam,DC=COM', 'distinguishedname' => ['count' => 1, 'CN=Karen Berge,CN=admin,DC=corp,DC=Fabrikam,DC=COM']], 1 => [0 => 'distinguishedname', 'count' => 1, 'dn' => 'CN=Doe\\, John,CN=admin,DC=corp,DC=Fabrikam,DC=COM', 'distinguishedname' => ['count' => 1, 'CN=Doe\\, John,CN=admin,DC=corp,DC=Fabrikam,DC=COM']], 2 => [0 => 'cn', 'cn' => ['count' => 1, 0 => 'Test'], 'distinguishedname' => ['count' => 1, 0 => 'CN=Bauman\\, Steve,OU=Users,OU=Developers,OU=User Accounts,OU=Canada,DC=corp,DC=Fabrikam,DC=COM'], 1 => 'distinguishedname', 'displayname' => ['count' => 1, 0 => 'Bauman, Steve'], 2 => 'displayname', 'samaccountname' => ['count' => 1, 0 => 'stevebauman'], 3 => 'samaccountname', 'count' => 4, 'dn' => 'CN=Bauman\\, Steve,OU=Users,OU=Developers,OU=User Accounts,OU=Canada,DC=corp,DC=Fabrikam,DC=COM']];
     $explodedDnsToReturn = [ldap_explode_dn($returnedLdapEntries[0]['dn'], 1), ldap_explode_dn($returnedLdapEntries[1]['dn'], 1), ldap_explode_dn($returnedLdapEntries[2]['dn'], 1)];
     $connection = $this->newConnectionMock();
     $connection->shouldReceive('explodeDn')->times(3)->andReturnValues($explodedDnsToReturn)->shouldReceive('close')->andReturn(true);
     $expectedResults = [['distinguishedname' => 'CN=Karen Berge,CN=admin,DC=corp,DC=Fabrikam,DC=COM', 'dn' => 'CN=Karen Berge,CN=admin,DC=corp,DC=Fabrikam,DC=COM', 'dn_array' => ['count' => 5, 0 => 'Karen Berge', 1 => 'admin', 2 => 'corp', 3 => 'Fabrikam', 4 => 'COM']], ['distinguishedname' => 'CN=Doe\\, John,CN=admin,DC=corp,DC=Fabrikam,DC=COM', 'dn' => 'CN=Doe\\, John,CN=admin,DC=corp,DC=Fabrikam,DC=COM', 'dn_array' => ['count' => 5, 0 => 'Doe\\2C John', 1 => 'admin', 2 => 'corp', 3 => 'Fabrikam', 4 => 'COM']], ['cn' => 'Test', 'displayname' => 'Bauman, Steve', 'samaccountname' => 'stevebauman', 'distinguishedname' => 'CN=Bauman\\, Steve,OU=Users,OU=Developers,OU=User Accounts,OU=Canada,DC=corp,DC=Fabrikam,DC=COM', 'dn' => 'CN=Bauman\\, Steve,OU=Users,OU=Developers,OU=User Accounts,OU=Canada,DC=corp,DC=Fabrikam,DC=COM', 'dn_array' => ['count' => 8, 0 => 'Bauman\\2C Steve', 1 => 'Users', 2 => 'Developers', 3 => 'User Accounts', 4 => 'Canada', 5 => 'corp', 6 => 'Fabrikam', 7 => 'COM']]];
     $entries = [];
     for ($i = 0; $i < $returnedLdapEntries["count"]; $i++) {
         $entry = new Entry($returnedLdapEntries[$i], $connection);
         $entries[] = $entry->getAttributes();
     }
     $this->assertEquals($expectedResults, $entries);
 }
开发者ID:ishawge,项目名称:jorani,代码行数:14,代码来源:LdapEntryTest.php

示例12: dnToName

/**
 * Answer a string name for a DN
 *
 * @param string $dn
 * @return string
 * @access public
 * @since 8/31/09
 */
function dnToName($dn)
{
    $levels = ldap_explode_dn($dn, 1);
    unset($levels['count']);
    // 	if (preg_match('/Miles/i', $dn)) {
    // 		var_dump($dn);
    // 		var_dump($levels);
    // 		exit;
    // 	}
    if (count($levels) <= 2) {
        return implode('.', $levels);
    } else {
        return str_replace('\\2C', ',', $levels[0]);
    }
}
开发者ID:HadoDokis,项目名称:AD_Group_Manager,代码行数:23,代码来源:functions.php

示例13: parseLdapDn

 public function parseLdapDn($dn)
 {
     $parsr = ldap_explode_dn($dn, 0);
     $out = array();
     foreach ($parsr as $key => $value) {
         if (FALSE !== strstr($value, '=')) {
             list($prefix, $data) = explode("=", $value);
             $data = preg_replace("/\\\\([0-9A-Fa-f]{2})/e", "''.chr(hexdec('\\1')).''", $data);
             if (isset($current_prefix) && $prefix == $current_prefix) {
                 $out[$prefix][] = $data;
             } else {
                 $current_prefix = $prefix;
                 $out[$prefix][] = $data;
             }
         }
     }
     return $out;
 }
开发者ID:NMonst4,项目名称:Adldap2Bundle,代码行数:18,代码来源:Adldap2Controller.php

示例14: assign

 private function assign($computer)
 {
     if (array_key_exists(0, $computer) && $computer['count'] > 0) {
         if (array_key_exists('dn', $computer[0])) {
             $this->dn = ldap_explode_dn($computer[0]['dn'], 1);
             $this->name = $this->dn[0];
             if (array_key_exists(1, $this->dn)) {
                 $this->group = $this->dn[1];
             }
             if (array_key_exists(2, $this->dn)) {
                 $this->type = $this->dn[2];
             }
             if (array_key_exists('dnshostname', $computer[0])) {
                 $this->host_name = $computer[0]['dnshostname'][0];
             }
             $this->os = new ComputerOs($computer[0]);
         }
     }
 }
开发者ID:stevebauman,项目名称:corp,代码行数:19,代码来源:Computer.php

示例15: ldap_process

function ldap_process($user, $pass)
{
    require_once QA_INCLUDE_DIR . "../qa-plugin/qa-ldap-login/ldap-config.php";
    // Establish link with LDAP server
    $con = ldap_connect($hostname, $port) or die("Could not connect to ldap host.");
    if (!is_resource($con)) {
        trigger_error("Unable to connect to {$hostname}", E_USER_WARNING);
    }
    ldap_set_option($con, LDAP_OPT_PROTOCOL_VERSION, 3);
    ldap_set_option($con, LDAP_OPT_REFERRALS, 0);
    // Removing @email.com
    if (strstr($user, '@')) {
        $parts = preg_split("/@/", $user);
        $user = $parts[0];
    }
    // Check if user/pass combo authenticates
    $bind = ldap_bind($con, $user . $account_suffix, $pass);
    if ($bind) {
    } else {
        return false;
    }
    // Connect to LDAP with read-only admin account
    $bind = ldap_bind($con, $username . $account_suffix, $password);
    if ($bind) {
        // Run query to determine user's name
        // Replace DOMAIN & com with ldap domain info
        $dn = "CN=Users,DC=DOMAIN,DC=com";
        $filter = "(&(objectClass=user)(sAMAccountName=" . $uname . "))";
        $attributes = array("displayname");
        $search = ldap_search($con, $dn, $filter, $attributes);
        $data = ldap_get_entries($con, $search);
        $explode = ldap_explode_dn($data[0]["dn"], 0);
        $name = explode(" ", str_replace("CN=", "", $explode[0]));
        // Close LDAP link
        ldap_close($con);
        // Return user's name in array
        $name[2] = $user;
        return $name;
    }
}
开发者ID:robkub,项目名称:qa-ldap-login,代码行数:40,代码来源:qa-ldap-process.php


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