[cvs] [Wiki] changed: CustomizingPreferences
Wiki Guest
wikiguest at horde.org
Thu Jun 21 10:46:22 UTC 2007
guest [62.58.32.70] Thu, 21 Jun 2007 03:46:22 -0700
Modified page: http://wiki.horde.org/CustomizingPreferences
New Revision: 3.0
Change log: different way to construct full_name
@@ -98,8 +98,44 @@
</code>
CW
+Another way to construct full name from givenName and sn
+<code type="php">
+if (!function_exists('_prefs_hook_fullname')) {
+ function _prefs_hook_fullname($user = null)
+ {
+ $ldapServer = '127.0.0.1';
+ $ldapPort = '389';
+ $searchBase = 'ou=OU_Extern,O=ARNHEM';
+
+ $ds = @ldap_connect($ldapServer, $ldapPort);
+
+ if (is_null($user)) {
+ $user = Auth::getAuth();
+ }
+ $searchResult = @ldap_search($ds, $searchBase, 'cn=' . $user);
+ $information = @ldap_get_entries($ds, $searchResult);
+ if ($information['count'] > 0) {
+ $name = '';
+ if ($information[0]['givenName'][0] != '') {
+ $name = $information[0]['givenName'][0];
+ }
+ if ($information[0]['sn'][0] !='') {
+ $name = $name . $information[0]['sn'][0];
+ }
+ if ($name == '') {
+ $name = $information[0]['cn'][0];
+ }
+ }
+
+ ldap_close($ds);
+
+ return (empty($name) ? $user : $name);
+ }
+}
+
+</code>
----
This function uses horde's LDAP config to pull the fullname from the LDAP
directory.
More information about the cvs
mailing list