Created
January 16, 2014 12:06
-
-
Save egulhan/8453837 to your computer and use it in GitHub Desktop.
How to delete one value from a multiple-valued attribute of LDAP by ldap_mode_del() function.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Removes member(s) from alias(es). | |
* @param mixed (string|array) member(s) | |
* @param mixed (string|array) alias(es) | |
* @return bool | |
*/ | |
public function removeMemberFromAlias($member,$alias=null) | |
{ | |
if(is_string($member)) | |
$member=array($member); | |
foreach($member as $mem) | |
{ | |
// Not set alias, search all aliases | |
if(!isset($alias)) | |
$alias=$this->filter('(&(objectClass=Alias)(mailForwardingAddress='.$mem.'))',array('uid')); | |
else if(is_string($alias)) | |
$alias=array($alias); | |
foreach($alias as $al) | |
{ | |
$al=$al['uid']; | |
$alDN=$this->getUserDN($al); | |
/** | |
* HERE IT IS | |
*/ | |
$delEntry=array('mailForwardingAddress'=>$mem); | |
$r=@ldap_mod_del($this->activeConnection,$alDN,$delEntry); | |
if(!$r) | |
{ | |
$errorMessage=sprintf('Can not remove alias member %s from %s: %s',$mem,$al,ldap_error($this->activeConnection)); | |
return $this->syslogger($errorMessage); | |
} | |
} | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment