本文整理汇总了PHP中ldap_list函数的典型用法代码示例。如果您正苦于以下问题:PHP ldap_list函数的具体用法?PHP ldap_list怎么用?PHP ldap_list使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ldap_list函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: search_uidspip
function search_uidspip ($filter,$ldap_server, $ldap_port, $dn) {
global $ldap_grp_attr;
// LDAP attributs
$ldap_grp_attr = array (
"cn",
"memberuid" );
$ds = @ldap_connect ( $ldap_server, $ldap_port );
if ( $ds ) {
$r = @ldap_bind ( $ds ); // Bind anonyme
if ($r) {
$result=@ldap_list ($ds, $dn["groups"], $filter, $ldap_grp_attr);
if ($result) {
$info = ldap_get_entries( $ds, $result );
if ($info["count"]) {
// Stockage des logins des membres des classes
// dans le tableau $ret
$init=0;
for ($loop=0; $loop < $info["count"]; $loop++) {
$group=split ("[\_\]",$info[$loop]["cn"][0],2);
for ( $i = 0; $i < $info[$loop]["memberuid"]["count"]; $i++ ) {
$ret[$init]["uid"] = $info[$loop]["memberuid"][$i];
$ret[$init]["cat"] = $group[0];
$init++;
}
}
}
ldap_free_result ( $result );
}
}
@ldap_close ( $ds );
}
return $ret;
}
示例2: getAllUsers
public function getAllUsers()
{
// Settings for LDAP
if ($this->container->hasParameter('ldap_host')) {
$ldapHostname = $this->container->getParameter("ldap_host");
$ldapPort = $this->container->getParameter("ldap_port");
$ldapVersion = $this->container->getParameter("ldap_version");
$baseDn = $this->container->getParameter("ldap_user_base_dn");
$nameAttribute = $this->container->getParameter("ldap_user_name_attribute");
$filter = "(" . $nameAttribute . "=*)";
$connection = @ldap_connect($ldapHostname, $ldapPort);
ldap_set_option($connection, LDAP_OPT_PROTOCOL_VERSION, $ldapVersion);
$ldapListRequest = ldap_list($connection, $baseDn, $filter);
// or throw exeption('Unable to list. LdapError: ' . ldap_error($ldapConnection));
$ldapUserList = ldap_get_entries($connection, $ldapListRequest);
}
// Settings for local user database
$repo = $this->getDoctrine()->getRepository('FOMUserBundle:User');
$users = $repo->findAll();
$all = array();
if ($this->container->hasParameter('ldap_host')) {
// Add Users from LDAP
foreach ($ldapUserList as $ldapUser) {
$user = new \stdClass();
$user->getUsername = $ldapUser[$nameAttribute][0];
$all[] = $user;
}
}
// Add Mapbenderusers from database
foreach ($users as $user) {
$all[] = $user;
}
return $all;
}
示例3: search
/**
* search ldap tree
* @param $filter ldap filter string to use
* @param string $ldap_scope scope either one or tree
* @return array|bool result list or false on errors
*/
private function search($filter, $ldap_scope = "tree")
{
$result = false;
if ($this->ldapHandle != null) {
// if we're looking at multple dn's, split and combine output
foreach (explode(";", $this->baseSearchDN) as $baseDN) {
if ($ldap_scope == "one") {
$sr = @ldap_list($this->ldapHandle, $baseDN, $filter, $this->ldapSearchAttr);
} else {
$sr = @ldap_search($this->ldapHandle, $baseDN, $filter, $this->ldapSearchAttr);
}
if ($sr !== false) {
$info = @ldap_get_entries($this->ldapHandle, $sr);
if ($info !== false) {
if ($result === false) {
$result = array();
$result['count'] = 0;
}
for ($i = 0; $i < $info["count"]; $i++) {
$result['count']++;
$result[] = $info[$i];
}
}
}
}
}
return $result;
}
示例4: is_prof
function is_prof($login)
{
global $ldap_server, $ldap_port, $dn;
global $error;
$error = "";
$filter = "(&(cn=profs*)(memberUid={$login}))";
$ldap_groups_attr = array("cn", "memberUid");
/*-----------------------------------------------------*/
$ds = @ldap_connect($ldap_server, $ldap_port);
if ($ds) {
$r = @ldap_bind($ds);
if (!$r) {
$error = "Echec du bind anonyme";
} else {
// Recherche du groupe d'appartenance de l'utilisateur connecte
$result = @ldap_list($ds, $dn["groups"], $filter, $ldap_groups_attr);
if ($result) {
$info = @ldap_get_entries($ds, $result);
if ($info["count"]) {
$is_prof = true;
} else {
$is_prof = false;
}
}
}
}
@ldap_unbind($ds);
@ldap_close($ds);
return $is_prof;
}
示例5: getOrganizations
private function getOrganizations()
{
// Common functions
$common = new common();
// Ldap Connections
$ldap = $common->ldapConnect($this->ldap_host, $this->ldap_root_dn, $this->ldap_root_pw);
if ($ldap) {
$filter = "objectClass=organizationalUnit";
$justthese = array("ou");
$search = ldap_list($ldap, $this->ldap_context, $filter, $justthese);
$entry = ldap_get_entries($ldap, $search);
}
if ($entry['count'] > 0) {
foreach ($entry as $tmp) {
if ($tmp['ou'][0] != "") {
$result_ou[] = $tmp['ou'][0];
}
}
} else {
$result_ou[] = $this->ldap_context;
}
natcasesort($result_ou);
ldap_close($ldap);
return $result_ou ? $result_ou : '';
}
示例6: searchonelevel
function searchonelevel($ldap, $base, $filter, $attrs, $minresults = 1, $maxresults = 999999)
{
$results = ldap_list($ldap, $base, $filter, $attrs);
$results or ldapdie($ldap, "ldap_list()");
$entries = ldap_get_entries($ldap, $results);
$entries or ldapdie($ldap, "ldap_get_entries()");
$entries["count"] <= $maxresults or ldapdie($ldap, "More than {$maxresults} object(s) match \"{$filter}\"");
$entries["count"] >= $minresults or ldapdie($ldap, "Could not find {$minresults} object(s) matching \"{$filter}\"");
return $entries;
}
示例7: ldap_search_withScope
function ldap_search_withScope($ds, $basedn, $filter, $attrlist, $scope)
{
if ($scope == "base") {
$search = ldap_read($ds, $basedn, $filter, $attrlist);
} elseif ($scope == "one") {
$search = ldap_list($ds, $basedn, $filter, $attrlist);
} elseif ($scope == "sub") {
$search = ldap_search($ds, $basedn, $filter, $attrlist);
}
return $search;
}
示例8: readUsers
public static function readUsers($ldapconn)
{
$users = array();
$search = ldap_list($ldapconn, USER_DN, User::FILTER_USERS, array("cn", "mail", "displayName", "sn", "givenName", "memberOf"));
if (ldap_count_entries($ldapconn, $search) > 0) {
$entry = ldap_first_entry($ldapconn, $search);
do {
$users[] = User::readFromLdapEntry($ldapconn, $entry);
} while ($entry = ldap_next_entry($ldapconn, $entry));
}
return $users;
}
示例9: my_people_get_variables
function my_people_get_variables ($serveur,$port,$Dn)
{
$ldap_server=$serveur;
$ldap_port=$port;
$dn=$Dn;
global $error;
$error="";
// LDAP attribute
$ldap_group_attr = array (
"cn",
"memberuid",
"description", // Description du groupe
);
$ds = @ldap_connect ( $ldap_server, $ldap_port );
if ( $ds ) {
$r = @ldap_bind ( $ds ); // Bind anonyme
if ($r) {
// Recherche des groupes d'appartenance dans la branche Groups
$filter = "(&(objectclass=posixGroup))";
$result = @ldap_list ( $ds, $dn["groups"], $filter, $ldap_group_attr );
if ($result) {
$info = @ldap_get_entries ( $ds, $result );
if ( $info["count"]) {
for ($loop=0; $loop<$info["count"];$loop++) {
//if ($info[$loop]["member"][0] == "") $typegr="posixGroup"; else $typegr="groupOfNames";
$typegr="posixGroup";
$ret_group[$loop] = array (
"cn" => $info[$loop]["cn"][0],
//"owner" => $info[$loop]["owner"][0],
"description" => utf8_decode($info[$loop]["description"][0]),
"type" => $typegr
);
}
usort($ret_group, "cmp_cn");
}
@ldap_free_result ( $result );
}
// Fin recherche des groupes
} else {
$error = "Echec du bind anonyme";
}
@ldap_close ( $ds );
} else {
$error = "Erreur de connection au serveur LDAP";
}
return array( $ret_group);
}
示例10: deleteRecord
/**
* @return boolean
* @param ResourceBundle $connection
* @param string $connection
* @param boolean $recursive
*/
public function deleteRecord($connection, $dn, $recursive = false)
{
if ($recursive == false) {
return ldap_delete($connection, $dn);
} else {
$sr = ldap_list($connection, $dn, "ObjectClass=*", array(""));
$info = ldap_get_entries($connection, $sr);
for ($i = 0; $i < $info['count']; $i++) {
$result = myldap_delete($connection, $info[$i]['dn'], $recursive);
if (!$result) {
return $result;
}
}
return ldap_delete($connection, $dn);
}
}
示例11: lda_del
/**
* suppression d'entrees OpenLDAP
* recursivite possible
*/
function lda_del($ldapconn, $dn, $recursive = FALSE)
{
if ($recursive == FALSE) {
return ldap_delete($ldapconn, $dn);
} else {
$sr = ldap_list($ldapconn, $dn, "ObjectClass=*");
$info = ldap_get_entries($ldapconn, $sr);
for ($i = 0; $i < $info['count']; $i++) {
$result = lda_del($ldapconn, $info[$i]['dn'], $recursive);
if (!$result) {
return $result;
}
}
return ldap_delete($ldapconn, $dn);
}
}
示例12: search
public function search($base, $depth, $filter, $attrs = array('cn'))
{
$attrs = array_values(array_unique($attrs));
if ($depth == 'one') {
if (($data = ldap_list($this->ldap, $base, $filter, $attrs)) === FALSE) {
throw new LDAPException('ldap_list() failed', $this->ldap);
}
} else {
if (($data = ldap_search($this->ldap, $base, $filter, $attrs)) === FALSE) {
throw new LDAPException('ldap_search() failed', $this->ldap);
}
}
if (($result = ldap_get_entries($this->ldap, $data)) === FALSE) {
throw new LDAPException('ldap_get_entries() failed', $this->ldap);
}
return $result;
}
示例13: query
public function query(LdapQuery $query)
{
set_error_handler($this->eh);
switch ($query->scope) {
case LDAP_SCOPE_SUBTREE:
$sr = ldap_search($this->ds, $query->base, $query->filter, $query->attrs, 0, $query->sizeLimit, $query->timeLimit, $query->deref);
break;
case LDAP_SCOPE_ONELEVEL:
$sr = ldap_list($this->ds, $query->base, $query->filter, $query->attrs, 0, $query->sizeLimit, $query->timeLimit, $query->deref);
break;
case LDAP_SCOPE_BASE:
$sr = ldap_read($this->ds, $query->base, $query->filter, $query->attrs, 0, $query->sizeLimit, $query->timeLimit, $query->deref);
break;
default:
throw new LdapException("Unknown query scope");
}
restore_error_handler();
return new LdapEntries($this->ds, $sr);
}
示例14: login
public function login($username, $password)
{
$CI =& get_instance();
$config = $CI->config->item("auth_ldap");
if ($username == "" || $password == "") {
return false;
}
$ds = ldap_connect($config['host'], $config['port']);
if ($ds === false) {
return false;
}
switch ($config["scope"]) {
case "base":
$r = ldap_read($ds, $config['basedn'], $config["username_field"] . '=' . $username);
break;
case "one":
$r = ldap_list($ds, $config['basedn'], $config["username_field"] . '=' . $username);
break;
case "subtree":
$r = ldap_search($ds, $config['basedn'], $config["username_field"] . '=' . $username);
break;
default:
throw new \exceptions\ApiException("libraries/duser/ldap/invalid-ldap-scope", "Invalid LDAP scope");
}
if ($r === false) {
return false;
}
foreach ($config["options"] as $key => $value) {
if (ldap_set_option($ds, $key, $value) === false) {
return false;
}
}
$result = ldap_get_entries($ds, $r);
if ($result === false || !isset($result[0])) {
return false;
}
// ignore errors from ldap_bind as it will throw an error if the password is incorrect
if (@ldap_bind($ds, $result[0]['dn'], $password)) {
ldap_unbind($ds);
return array("username" => $result[0][$config["username_field"]][0], "userid" => $result[0][$config["userid_field"]][0]);
}
return false;
}
示例15: delete_ldap
function delete_ldap($dn, $connect, $recursive = false)
{
if ($recursive == false) {
if (!@ldap_delete($connect, $dn)) {
echo "Deleting {$dn}...\n";
echo "ERROR: ldap_delete \"{$dn}\"" . ldap_err2str(ldap_errno($connect)) . "\n";
return false;
}
}
$sr = @ldap_list($connect, $dn, "ObjectClass=*");
if ($sr) {
$info = @ldap_get_entries($connect, $sr);
for ($i = 0; $i < $info['count']; $i++) {
$result = delete_ldap($info[$i]['dn'], $connect, $recursive);
if (!$result) {
return $result;
}
}
return delete_ldap($dn, $connect, false);
}
}