fg.php

来自「PHP 知识管理系统(基于树结构的知识管理系统), 英文原版的PHP源码。」· PHP 代码 · 共 39 行

PHP
39
字号
<?php

require_once('../../../../config/dmsDefaults.php');
require_once(KT_LIB_DIR . '/authentication/authenticationutil.inc.php');
require_once(KT_LIB_DIR . '/authentication/authenticationsource.inc.php');

require_once('Net/LDAP.php');

$oKTConfig =& KTConfig::getSingleton();

$oAuthenticator = KTAuthenticationUtil::getAuthenticatorForSource(2);

$config = array(
    'dn' => $oAuthenticator->sSearchUser,
    'password' => $oAuthenticator->sSearchPassword,
    'host' => $oAuthenticator->sLdapServer,
    'base' => $oAuthenticator->sBaseDN,
);

$oLdap =& Net_LDAP::connect($config);
if (PEAR::isError($oLdap)) {
    var_dump($oLdap);
    exit(0);
}

$aParams = array(
    'scope' => 'sub',
    'attributes' => array('cn', 'dn', 'displayClass'),
);
$rootDn = $oAuthenticator->sBaseDN;
if (is_array($rootDn)) {
    $rootDn = join(",", $rootDn);
}
$oResults = $oLdap->search($rootDn, '(objectClass=group)', $aParams);
foreach ($oResults->entries() as $oEntry) {
    var_dump($oEntry->dn());
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?