本文整理汇总了PHP中Zend_Ldap_Dn类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Ldap_Dn类的具体用法?PHP Zend_Ldap_Dn怎么用?PHP Zend_Ldap_Dn使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Ldap_Dn类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testUnescapeValues
public function testUnescapeValues()
{
$dnval = '\\20\\20\\16\\20t\\,e\\+s \\"t\\,\\\\v\\<a\\>l\\;u\\#e\\=!\\20\\20\\20\\20';
$expected = ' ' . chr(22) . ' t,e+s "t,\\v<a>l;u#e=! ';
$this->assertEquals($expected, Zend_Ldap_Dn::unescapeValue($dnval));
$this->assertEquals($expected, Zend_Ldap_Dn::unescapeValue(array($dnval)));
$this->assertEquals(array($expected, $expected, $expected), Zend_Ldap_Dn::unescapeValue(array($dnval, $dnval, $dnval)));
}
示例2: isValid
/**
* Defined by Zend_Validate_Interface.
*
* Returns true if and only if $value is a valid DN.
*
* @param string $value The value to be validated.
*
* @return boolean
*/
public function isValid($value)
{
$valid = Zend_Ldap_Dn::checkDn($value);
if ($valid === false) {
$this->_error(self::MALFORMED);
return false;
}
return true;
}
示例3: getDomainConfiguration
/**
* fetch domain config with domain sid and name
*
* @throws Tinebase_Exception_Backend_Ldap
* @throws Zend_Ldap_Exception
* @return array
*
* TODO cache this longer?
*/
public function getDomainConfiguration()
{
if ($this->_domainConfig === null) {
$this->_domainConfig = $this->getLdap()->search('objectClass=domain', $this->getLdap()->getFirstNamingContext(), Zend_Ldap::SEARCH_SCOPE_BASE)->getFirst();
$this->_domainConfig['domainSidBinary'] = $this->_domainConfig['objectsid'][0];
$this->_domainConfig['domainSidPlain'] = Tinebase_Ldap::decodeSid($this->_domainConfig['objectsid'][0]);
$domainNameParts = array();
$keys = null;
// not really needed
Zend_Ldap_Dn::explodeDn($this->_domainConfig['distinguishedname'][0], $keys, $domanNameParts);
$this->_domainConfig['domainName'] = implode('.', $domainNameParts);
}
return $this->_domainConfig;
}
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:23,代码来源:DomainConfigurationTrait.php
示例4: testIsChildOfParentDnLonger
public function testIsChildOfParentDnLonger()
{
$dn1 = 'dc=example,dc=de';
$dn2 = 'cb=name1,cn=name2,dc=example,dc=org';
$this->assertFalse(Zend_Ldap_Dn::isChildOf($dn1, $dn2));
}
示例5: __construct
/**
* the constructor
*
* @param array $options Options used in connecting, binding, etc.
*/
public function __construct(array $_options)
{
if (empty($_options['userUUIDAttribute'])) {
$_options['userUUIDAttribute'] = 'objectGUID';
}
if (empty($_options['groupUUIDAttribute'])) {
$_options['groupUUIDAttribute'] = 'objectGUID';
}
if (empty($_options['baseDn'])) {
$_options['baseDn'] = $_options['userDn'];
}
if (empty($_options['userFilter'])) {
$_options['userFilter'] = 'objectclass=user';
}
if (empty($_options['userSearchScope'])) {
$_options['userSearchScope'] = Zend_Ldap::SEARCH_SCOPE_SUB;
}
if (empty($_options['groupFilter'])) {
$_options['groupFilter'] = 'objectclass=group';
}
parent::__construct($_options);
// get domain sid
$this->_domainConfig = $this->getLdap()->search('objectClass=domain', $this->getLdap()->getFirstNamingContext(), Zend_Ldap::SEARCH_SCOPE_BASE)->getFirst();
$this->_domainSidBinary = $this->_domainConfig['objectsid'][0];
$this->_domainSidPlain = Tinebase_Ldap::decodeSid($this->_domainConfig['objectsid'][0]);
$domanNameParts = array();
Zend_Ldap_Dn::explodeDn($this->_domainConfig['distinguishedname'][0], $fooBar, $domanNameParts);
$this->_domainName = implode('.', $domanNameParts);
}
示例6: isChildOf
/**
* Checks if given $childDn is beneath $parentDn subtree.
*
* @param string|Zend_Ldap_Dn $childDn
* @param string|Zend_Ldap_Dn $parentDn
* @return boolean
*/
public static function isChildOf($childDn, $parentDn)
{
try {
$keys = array();
$vals = array();
if ($childDn instanceof Zend_Ldap_Dn) {
$cdn = $childDn->toArray(Zend_Ldap_Dn::ATTR_CASEFOLD_LOWER);
} else {
$cdn = self::explodeDn($childDn, $keys, $vals, Zend_Ldap_Dn::ATTR_CASEFOLD_LOWER);
}
if ($parentDn instanceof Zend_Ldap_Dn) {
$pdn = $parentDn->toArray(Zend_Ldap_Dn::ATTR_CASEFOLD_LOWER);
} else {
$pdn = self::explodeDn($parentDn, $keys, $vals, Zend_Ldap_Dn::ATTR_CASEFOLD_LOWER);
}
} catch (Zend_Ldap_Exception $e) {
return false;
}
$startIndex = count($cdn) - count($pdn);
if ($startIndex < 0) {
return false;
}
for ($i = 0; $i < count($pdn); $i++) {
if ($cdn[$i + $startIndex] != $pdn[$i]) {
return false;
}
}
return true;
}
示例7: testLoadFromLdapWithDnObject
public function testLoadFromLdapWithDnObject()
{
$dn = Zend_Ldap_Dn::fromString($this->_createDn('ou=Test1,'));
$node = Zend_Ldap_Node::fromLdap($dn, $this->_getLdap());
$this->assertType('Zend_Ldap_Node', $node);
$this->assertTrue($node->isAttached());
}
示例8: getSchemaDn
/**
* Returns the schema DN
*
* @return Zend_Ldap_Dn
*/
public function getSchemaDn()
{
$schemaDn = $this->getSchemaNamingContext();
/**
* @see Zend_Ldap_Dn
*/
require_once 'Zend/Ldap/Dn.php';
return Zend_Ldap_Dn::fromString($schemaDn);
}
示例9: testImplodeRdnInvalidThree
/**
* @expectedException Zend_Ldap_Exception
*/
public function testImplodeRdnInvalidThree()
{
$a = array('cn' => 'value', 'ou');
Zend_Ldap_Dn::implodeRdn($a);
}
示例10: testSaveWithDnObject
public function testSaveWithDnObject()
{
$dn = Zend_Ldap_Dn::fromString($this->_createDn('ou=TestCreated,'));
$data = array('ou' => 'TestCreated', 'objectclass' => 'organizationalUnit');
try {
$this->_getLdap()->save($dn, $data);
$this->assertTrue($this->_getLdap()->exists($dn));
$data['l'] = 'mylocation1';
$this->_getLdap()->save($dn, $data);
$this->assertTrue($this->_getLdap()->exists($dn));
$entry = $this->_getLdap()->getEntry($dn);
$this->_getLdap()->delete($dn);
$this->assertEquals('mylocation1', $entry['l'][0]);
} catch (Zend_Ldap_Exception $e) {
if ($this->_getLdap()->exists($dn)) {
$this->_getLdap()->delete($dn);
}
$this->fail($e->getMessage());
}
}
示例11: updateUserInSyncBackend
/**
* updates an existing user
*
* @todo check required objectclasses?
*
* @param Tinebase_Model_FullUser $_account
* @return Tinebase_Model_FullUser
*/
public function updateUserInSyncBackend(Tinebase_Model_FullUser $_account)
{
if ($this->_isReadOnlyBackend) {
return;
}
Tinebase_Group::getInstance()->addGroupMemberInSyncBackend($_account->accountPrimaryGroup, $_account->getId());
$ldapEntry = $this->_getLdapEntry('accountId', $_account);
$ldapData = $this->_user2ldap($_account, $ldapEntry);
foreach ($this->_ldapPlugins as $plugin) {
$plugin->inspectUpdateUser($_account, $ldapData, $ldapEntry);
}
// do we need to rename the entry?
// TODO move to rename()
$dn = Zend_Ldap_Dn::factory($ldapEntry['dn'], null);
$rdn = $dn->getRdn();
if ($rdn['CN'] != $ldapData['cn']) {
$newDN = $this->generateDn($_account);
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' rename ldap entry to: ' . $newDN);
}
$this->_ldap->rename($dn, $newDN);
}
// no need to update this attribute, it's not allowed to change and even might not be updateable
unset($ldapData[$this->_userUUIDAttribute]);
// remove cn as samba forbids updating the CN (even if it does not change...
// 0x43 (Operation not allowed on RDN; 00002016: Modify of RDN 'CN' on CN=...,CN=Users,DC=example,DC=org
// not permitted, must use 'rename' operation instead
unset($ldapData['cn']);
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' $dn: ' . $ldapEntry['dn']);
}
if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' $ldapData: ' . print_r($ldapData, true));
}
$this->_ldap->update($ldapEntry['dn'], $ldapData);
// refetch user from ldap backend
$user = $this->getUserByPropertyFromSyncBackend('accountId', $_account, 'Tinebase_Model_FullUser');
return $user;
}
示例12: _deletePropertyFromLdapRawData
/**
* (non-PHPdoc)
*/
protected function _deletePropertyFromLdapRawData($property, $value)
{
$ldapProperty = $this->_propertyMapping[$property];
if (substr($ldapProperty, -8) == ':boolean') {
$ldapProperty = substr($ldapProperty, 0, -8);
}
$managedPath = Zend_Ldap_Dn::fromString($this->_simpleMailConfig['storage_base'], Zend_Ldap_Dn::ATTR_CASEFOLD_LOWER);
foreach ($this->_ldapRawData as $index => $dn) {
// change only entries in storage_base path (if existing)
if (isset($dn['simplemail_readonly']) || !isset($dn[$ldapProperty])) {
continue;
}
if ($value === false) {
//unset doesn't remove attribute in ldap
$this->_ldapRawData[$index][$ldapProperty] = null;
} elseif (in_array($value, $this->_ldapRawData[$index][$ldapProperty])) {
$del_index = array_search($value, $this->_ldapRawData[$index][$ldapProperty]);
unset($this->_ldapRawData[$index][$ldapProperty][$del_index]);
// don't keep empty arrays
if (count($this->_ldapRawData[$index][$ldapProperty]) < 1) {
unset($this->_ldapRawData[$index][$ldapProperty]);
}
}
}
}
示例13: getSchemaDn
/**
* Returns the schema DN
*
* @return Zend_Ldap_Dn
*/
public function getSchemaDn()
{
$schemaDn = $this->getSubschemaSubentry();
/**
* @see Zend_Ldap_Dn
*/
return Zend_Ldap_Dn::fromString($schemaDn);
}
示例14: getSchemaDn
/**
* Returns the schema DN
*
* @return Zend_Ldap_Dn
*/
public function getSchemaDn()
{
$schemaDn = $this->getSchemaNamingContext();
/**
* @see Zend_Ldap_Dn
*/
return Zend_Ldap_Dn::fromString($schemaDn);
}
示例15: testSimpleRecursiveIteration
public function testSimpleRecursiveIteration()
{
$node = $this->_getLdap()->getBaseNode();
$ri = new RecursiveIteratorIterator($node, RecursiveIteratorIterator::SELF_FIRST);
$i = 0;
foreach ($ri as $rdn => $n) {
$dn = $n->getDn()->toString(Zend_Ldap_Dn::ATTR_CASEFOLD_LOWER);
$rdn = Zend_Ldap_Dn::implodeRdn($n->getRdnArray(), Zend_Ldap_Dn::ATTR_CASEFOLD_LOWER);
if ($i == 0) {
$this->assertEquals(Zend_Ldap_Dn::fromString(TESTS_ZEND_LDAP_WRITEABLE_SUBTREE)->toString(Zend_Ldap_Dn::ATTR_CASEFOLD_LOWER), $dn);
} else {
if ($i == 1) {
$this->assertEquals('ou=Node', $rdn);
$this->assertEquals($this->_createDn('ou=Node,'), $dn);
} else {
if ($i < 4) {
$j = $i - 1;
$base = $this->_createDn('ou=Node,');
} else {
$j = $i - 3;
$base = Zend_Ldap_Dn::fromString(TESTS_ZEND_LDAP_WRITEABLE_SUBTREE)->toString(Zend_Ldap_Dn::ATTR_CASEFOLD_LOWER);
}
$this->assertEquals('ou=Test' . $j, $rdn);
$this->assertEquals('ou=Test' . $j . ',' . $base, $dn);
}
}
$i++;
}
$this->assertEquals(9, $i);
}