浏览代码

Beta version of the LDAP authentication module: added parameters %2$s (first name), %3$s (first name) and %4$s (email) as possible placeholders into the LDAP query.

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@633 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 15 年之前
父节点
当前提交
68257d990d
共有 1 个文件被更改,包括 20 次插入1 次删除
  1. 20 1
      modules/authent-ldap/model.authent-ldap.php

+ 20 - 1
modules/authent-ldap/model.authent-ldap.php

@@ -89,7 +89,26 @@ class UserLDAP extends User
 			$sLDAPUserQuery = MetaModel::GetModuleSetting('authent-ldap', 'user_query', '');
 			$sBaseDN = MetaModel::GetModuleSetting('authent-ldap', 'base_dn', '');
 			
-			$sQuery = sprintf($sLDAPUserQuery, $this->Get('login'));
+			$sLogin = $this->Get('login');
+			$iContactId = $this->Get('contactid');
+			$sFirstName = '';
+			$sLastName = '';
+			$sEMail = '';
+			if ($iContactId > 0)
+			{
+				$oPerson = MetaModel::GetObject('Person', $iContactId);
+				if (is_object($oPerson))
+				{
+					$sFirstName = $oPerson->Get('first_name');
+					$sLastName = $oPerson->Get('name');
+					$sEMail = $oPerson->Get('email');
+				}
+			}
+			// %1$s => login
+			// %2$s => first name
+			// %3$s => last name			
+			// %4$s => email
+			$sQuery = sprintf($sLDAPUserQuery, $sLogin, $sFirstName, $sLastName, $sEMail);
 			$hSearchResult = @ldap_search($hDS, $sBaseDN, $sQuery);
 
 			$iCountEntries = ($hSearchResult !== false) ? @ldap_count_entries($hDS, $hSearchResult) : 0;