diff --git a/public_html/conf/LSaddons/config.LSaddons.posix.php b/public_html/conf/LSaddons/config.LSaddons.posix.php index c2e66926..938281d7 100644 --- a/public_html/conf/LSaddons/config.LSaddons.posix.php +++ b/public_html/conf/LSaddons/config.LSaddons.posix.php @@ -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.'=([^,]*),.*$/'); + ?> diff --git a/public_html/includes/addons/LSaddons.posix.php b/public_html/includes/addons/LSaddons.posix.php index c655eb72..9e4b5c5a 100644 --- a/public_html/includes/addons/LSaddons.posix.php +++ b/public_html/includes/addons/LSaddons.posix.php @@ -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; +} + ?>