本文整理汇总了PHP中ldap_explode_dn函数的典型用法代码示例。如果您正苦于以下问题:PHP ldap_explode_dn函数的具体用法?PHP ldap_explode_dn怎么用?PHP ldap_explode_dn使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ldap_explode_dn函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: assign
/**
* Assigns object variables from adldap array.
*
* @param $user
*/
private function assign($user)
{
if (array_key_exists('dn', $user[0])) {
$this->dn = ldap_explode_dn($user[0]['dn'], 1);
$this->dn_string = $user[0]['dn'];
}
if (array_key_exists('samaccountname', $user[0])) {
$this->username = $user[0]['samaccountname'][0];
}
if (array_key_exists('displayname', $user[0])) {
$this->name = $user[0]['displayname'][0];
}
if (array_key_exists('mail', $user[0])) {
$this->email = $user[0]['mail'][0];
}
if (array_key_exists(1, $this->dn)) {
$this->type = $this->dn[1];
}
if (array_key_exists(2, $this->dn)) {
$this->group = $this->dn[2];
}
}
开发者ID:stevebauman,项目名称:corp,代码行数:27,代码来源:User.php
示例17: createMainMenu
<?php
include '../standard_header.inc.php';
# 3. Dateiname und evtl. Pfad des Templates für die Webseite
$webseite = "new_pxe.dwt";
include 'rbs_header.inc.php';
###################################################################################
$mnr = -1;
$sbmnr = -1;
$mcnr = -1;
$mnr = $_GET['mnr'];
$sbmnr = $_GET['sbmnr'];
$mcnr = $_GET['mcnr'];
# Menuleisten erstellen
createMainMenu($rollen, $mainnr);
createRBSMenu($rollen, $mnr, $auDN, $sbmnr);
###################################################################################
$rbsDN = $_GET['rbsdn'];
$rbsdnexp = ldap_explode_dn($rbsDN, 1);
$pxecn = str_replace("_", " ", $_GET['pxecn']);
$pxeday = str_replace("_", " ", $_GET['pxeday']);
$pxebeg = str_replace("_", " ", $_GET['pxebeg']);
$pxeend = str_replace("_", " ", $_GET['pxeend']);
$template->assign(array("PXECN" => $pxecn, "PXEDAY" => $pxeday, "PXEBEG" => $pxebeg, "PXEEND" => $pxeend, "LDAPURI" => "", "FILEURI" => "", "RBSDN" => $rbsDN, "RBSCN" => $rbsdnexp[0], "RBSAU" => "", "NFS" => "", "NFSROOT" => "", "TFTP" => "", "TFTPROOT" => "", "FILE" => "", "ALLOW" => "", "CONSOLE" => "", "DEFAULT" => "menu.c32", "DISPLAY" => "", "FONT" => "", "IMPLICIT" => "", "KBDMAP" => "", "MENMPW" => "", "MENTIT" => "", "NOESC" => "1", "ONERR" => "", "ONTIME" => "", "PROMPT" => "0", "SAY" => "", "SERIAL" => "", "TIMEOUT" => "600", "MNR" => $mnr, "SBMNR" => $sbmnr));
###################################################################################
include "rbs_footer.inc.php";
开发者ID:BackupTheBerlios,项目名称:openslx-svn,代码行数:26,代码来源:new_pxe.php
示例18: ldap_add_user_by_array
function ldap_add_user_by_array($data, $update_if_exists = true)
{
$lastname = api_convert_encoding($data['sn'][0], api_get_system_encoding(), 'UTF-8');
$firstname = api_convert_encoding($data['cn'][0], api_get_system_encoding(), 'UTF-8');
$email = $data['mail'][0];
// Get uid from dn
$dn_array = ldap_explode_dn($data['dn'], 1);
$username = $dn_array[0];
// uid is first key
$outab[] = $data['edupersonprimaryaffiliation'][0];
// Here, "student"
//$val = ldap_get_values_len($ds, $entry, "userPassword");
//$val = ldap_get_values_len($ds, $data, "userPassword");
//$password = $val[0];
// TODO the password, if encrypted at the source, will be encrypted twice, which makes it useless. Try to fix that.
$password = $data['userPassword'][0];
$structure = $data['edupersonprimaryorgunitdn'][0];
$array_structure = explode(",", $structure);
$array_val = explode("=", $array_structure[0]);
$etape = $array_val[1];
$array_val = explode("=", $array_structure[1]);
$annee = $array_val[1];
// To ease management, we add the step-year (etape-annee) code
$official_code = $etape . "-" . $annee;
$auth_source = 'ldap';
// No expiration date for students (recover from LDAP's shadow expiry)
$expiration_date = '0000-00-00 00:00:00';
$active = 1;
if (empty($status)) {
$status = 5;
}
if (empty($phone)) {
$phone = '';
}
if (empty($picture_uri)) {
$picture_uri = '';
}
// Adding user
$user_id = 0;
if (UserManager::is_username_available($username)) {
$user_id = UserManager::create_user($firstname, $lastname, $status, $email, $username, $password, $official_code, api_get_setting('platformLanguage'), $phone, $picture_uri, $auth_source, $expiration_date, $active);
} else {
if ($update_if_exists) {
$user = UserManager::get_user_info($username);
$user_id = $user['user_id'];
UserManager::update_user($user_id, $firstname, $lastname, $username, null, null, $email, $status, $official_code, $phone, $picture_uri, $expiration_date, $active);
}
}
return $user_id;
}
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:50,代码来源:authldap.php
示例19: getContact
/**
* Returns a specfic contact.
*
* Same as getContacts except that either 'carddata' or 'vcard' is mandatory.
*
* @param string $addressbookid
* @param mixed $ids
* @return array|bool
*/
public function getContact($addressbookid, $ids, array $options = array())
{
if (!is_array($ids)) {
$a_ids = array($ids);
} else {
$a_ids = $ids;
}
$cards = array();
$toReturn = false;
if (self::setLdapParams($addressbookid)) {
foreach ($a_ids as $id) {
$cid = str_replace(".vcf", "", $id);
if (ldap_explode_dn(base64_decode($cid), 0) == false) {
$ldifEntry = $this->connector->getLdifEntry("X-URI", null);
$filter = "";
if (isset($ldifEntry[0]['unassigned'])) {
$filter = $this->connector->getUnassignedVCardProperty() . "=X-URI:" . $cid . "*";
} else {
$filter = $ldifEntry[0]['name'] . "=" . $cid . "*";
}
$card = self::ldapFindOne($this->ldapParams['ldapbasednsearch'], $filter, $this->connector->getLdapEntries());
} else {
$card = self::ldapFindOne(base64_decode($cid), $this->ldapParams['ldapfilter'], $this->connector->getLdapEntries());
}
}
if ($card != null) {
return self::getSabreFormatCard($addressbookid, $this->connector->ldapToVCard($card));
}
}
return false;
}
开发者ID:enoch85,项目名称:owncloud-testserver,代码行数:40,代码来源:ldap.php
示例20: array
$dhcpchange = 1;
} else {
# echo "kein Änderung <br>";
}
}
echo "</td><td width='33%' class='tab_d'>";
echo "<br><b>RemoteBoot Dienst:</b> <br><br>";
for ($j = 0; $j < count($rbs); $j++) {
$rbsadd = array();
$rbsdel = array();
$hostexp = ldap_explode_dn($hostDN[$j], 1);
if ($rbs[$j] != $oldrbs[$j]) {
echo "<b>{$hostexp['0']}</b> - ";
$exp = ldap_explode_dn($rbs[$j], 1);
$rbscn = $exp[0];
$oldexp = ldap_explode_dn($oldrbs[$j], 1);
$oldrbscn = $oldexp[0];
if ($rbs[$j] == "") {
$rbsdel['hlprbservice'] = array();
$rbsdel['dhcpoptnext-server'] = array();
$rbsdel['dhcpoptfilename'] = array();
$result = ldap_mod_del($ds, $hostDN[$j], $rbsdel);
if ($result) {
echo "erfolgreich ausgetragen, alter Wert: <b>{$oldrbscn}</b> <br>";
} else {
echo "Fehler beim austragen aus Remote Boot Dienst <b>{$oldrbscn}</b> <br>";
}
} else {
$rbsdhcpdata = get_node_data($rbs[$j], array("tftpserverip", "initbootfile"));
$rbsadd['hlprbservice'] = $rbs[$j];
$rbsadd['dhcpoptnext-server'] = $rbsdhcpdata['tftpserverip'];
开发者ID:BackupTheBerlios,项目名称:openslx-svn,代码行数:31,代码来源:ip_rechner_change.php
注:本文中的ldap_explode_dn函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论