From a27aef92060277120f8889136ed6972f5915709f Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Thu, 14 Jan 2010 19:43:03 -0500 Subject: Add nickname suggestion capability for use during autoregistration. --- plugins/LdapAuthentication/LdapAuthenticationPlugin.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'plugins/LdapAuthentication/LdapAuthenticationPlugin.php') diff --git a/plugins/LdapAuthentication/LdapAuthenticationPlugin.php b/plugins/LdapAuthentication/LdapAuthenticationPlugin.php index eb3a05117..1755033f1 100644 --- a/plugins/LdapAuthentication/LdapAuthenticationPlugin.php +++ b/plugins/LdapAuthentication/LdapAuthenticationPlugin.php @@ -153,6 +153,22 @@ class LdapAuthenticationPlugin extends AuthenticationPlugin return false; } + + function suggestNicknameForUsername($username) + { + $entry = $this->ldap_get_user($username, $this->attributes); + if(!$entry){ + //this really shouldn't happen + return $username; + }else{ + $nickname = $entry->getValue($this->attributes['nickname'],'single'); + if($nickname){ + return $nickname; + }else{ + return $username; + } + } + } //---utility functions---// function ldap_get_config(){ -- cgit v1.2.3-54-g00ecf