LSaddon::posix : added generate_memberUidFromUniqueMember() function

This commit is contained in:
Benjamin Renard 2013-06-24 17:38:26 +02:00
parent 9ba2f8591b
commit 350aff50c1
2 changed files with 28 additions and 1 deletions

View file

@ -59,4 +59,7 @@ define('LS_POSIX_HOMEDIRECTORY_FTP_PWD','password');
// Create homeDirectory by FTP - Path
define('LS_POSIX_HOMEDIRECTORY_FTP_PATH','%{homeDirectory}');
// Pattern to transform user DN to uid
define('LS_POSIX_DN_TO_UID_PATTERN','/^'.LS_POSIX_UID_ATTR.'=([^,]*),.*$/');
?>

View file

@ -66,7 +66,8 @@ LSerror :: defineError('POSIX_01',
'LS_POSIX_HOMEDIRECTORY_FTP_PORT',
'LS_POSIX_HOMEDIRECTORY_FTP_USER',
'LS_POSIX_HOMEDIRECTORY_FTP_PWD',
'LS_POSIX_HOMEDIRECTORY_FTP_PATH'
'LS_POSIX_HOMEDIRECTORY_FTP_PATH',
'LS_POSIX_DN_TO_UID_PATTERN',
);
foreach($MUST_DEFINE_CONST as $const) {
@ -210,5 +211,28 @@ function generateMemberFromMemberUid($ldapObject) {
}
function generate_memberUidFromUniqueMember($ldapObject) {
if ( get_class($ldapObject -> attrs[ 'memberUid' ]) != 'LSattribute' ) {
LSerror :: addErrorCode('POSIX_01',array('dependency' => 'memberUid', 'attr' => 'memberUid'));
return;
}
if ( get_class($ldapObject -> attrs[ 'uniqueMember' ]) != 'LSattribute' ) {
LSerror :: addErrorCode('POSIX_01',array('dependency' => 'uniqueMember', 'attr' => 'memberUid'));
return;
}
$dns = $ldapObject -> attrs[ 'uniqueMember' ] -> getValue();
$uids = array();
if (is_array($dns)) {
foreach($dns as $dn) {
if(preg_match(LS_POSIX_DN_TO_UID_PATTERN,$dn,$matches)) {
$uids[]=$matches[1];
}
}
}
return $uids;
}
?>