note 103349 rejected from function.ldap-mod-del by danbrown

From: Date: Fri, 08 Apr 2011 16:34:41 +0000
Subject: note 103349 rejected from function.ldap-mod-del by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-178642@lists.php.net to get a copy of this message
Note Submitter: b32607 at freescale dot com ---- I have been banging my head against the wall trying to use ldap_mod_del. I want to search through the groups and then gather the group name and remove the user from those groups. Here is my code: $toDelete = "b15042"; $uid = "memberuid=$toDelete"; //$username['user'] = 'uid=test,ou=people,ou=cde-tx32,ou=unix-domains,dc=motorola,dc=com'; // ldap rdn or dn $username['user'] = 'test'; $username['pass'] = 'test'; // associated password $basedn = "'ou=people,ou=unix-domains,dc=domain,dc=com"; // Connection Strings for LDAP $ldapconfig['host'] = 'connection'; $ldapconfig['port'] = 389; $ldapconfig['basedn'] = 'ou=people,ou=unix-domains,dc=domain,dc=com'; // BASEDN $dn="uid=".$username['user'].",ou=people,".$ldapconfig['basedn']; // connect to ldap server $ds = ldap_connect($ldapconfig['host'], $ldapconfig['port']) or die("Could not connect to LDAP server."); // binding to ldap server $login = ldap_bind($ds, $dn, $username['pass']); //////// $search = ldap_search($ds, "ou=group," . $ldapconfig['basedn'], "memberuid=$toDelete"); $groupList = ldap_get_entries($ds, $search); echo $groupList["count"] . " entries returned\n"; $cnGroups = array(); $info["memberuid"] = array(); for( $i=0; $i<$groupList["count"]; $i++ ) { if( sizeof($groupList[$i]["memberuid"]) != 0 ) { foreach ( $groupList[$i]["memberuid"] as $val ) { if ( $val == $toDelete ) { $cnGroups = "cn=" . $groupList[$i]['cn'][0] . ",$basedn"; $info["memberuid"] = $toDelete; echo "Deleting " . $toDelete . " from " . $cnGroups . "\n"; $remove = ldap_mod_del($ds, $cnGroups, $info); echo "$remove\n"; } } } } ?>

« previous php.notes (#178642) next »