Commit 031b8a1863e0a3856d4ef2920386bb4b70236d91

Authored by Neil Blakey-Milner
1 parent e41554e9

Add getAuthenticatorForSource and synchroniseGroupToSource

getAuthenticatorForSource provides a configured authenticator for the
source provided.

synchroniseGroupToSource tells a group-providing authenticator to
synchronise the group's membership from its source (e.g. LDAP)


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@4828 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/authentication/authenticationutil.inc.php
@@ -12,15 +12,26 @@ class KTAuthenticationUtil { @@ -12,15 +12,26 @@ class KTAuthenticationUtil {
12 } 12 }
13 13
14 function &getAuthenticatorForUser($oUser) { 14 function &getAuthenticatorForUser($oUser) {
15 - $iAuthenticationSourceId = $oUser->getAuthenticationSourceId();  
16 - if (empty($iAuthenticationSourceId)) {  
17 - $oProvider = new KTBuiltinAuthenticationProvider;  
18 - } else {  
19 - $oSource = KTAuthenticationSource::get($iAuthenticationSourceId); 15 + $iSourceId = $oUser->getAuthenticationSourceId();
  16 + return KTAuthenticationUtil::getAuthenticatorForSource($iSourceId);
  17 + }
  18 +
  19 + function &getAuthenticatorForSource($oSource) {
  20 + if ($oSource) {
  21 + $oSource =& KTUtil::getObject('KTAuthenticationSource', $oSource);
20 $sProvider = $oSource->getAuthenticationProvider(); 22 $sProvider = $oSource->getAuthenticationProvider();
21 $oRegistry =& KTAuthenticationProviderRegistry::getSingleton(); 23 $oRegistry =& KTAuthenticationProviderRegistry::getSingleton();
22 - $oProvider = $oRegistry->getAuthenticationProvider($sProvider); 24 + $oProvider =& $oRegistry->getAuthenticationProvider($sProvider);
  25 + } else {
  26 + $oProvider = new KTBuiltinAuthenticationProvider;
23 } 27 }
24 return $oProvider->getAuthenticator($oSource); 28 return $oProvider->getAuthenticator($oSource);
25 } 29 }
  30 +
  31 + function synchroniseGroupToSource($oGroup) {
  32 + $oGroup =& KTUtil::getObject('Group', $oGroup);
  33 + $iSourceId = $oGroup->getAuthenticationSourceId();
  34 + $oAuthenticator = KTAuthenticationUtil::getAuthenticatorForSource($iSourceId);
  35 + return $oAuthenticator->synchroniseGroup($oGroup);
  36 + }
26 } 37 }