http://www.mediawiki.org/wiki/Special:Code/MediaWiki/96043

Revision: 96043
Author:   laner
Date:     2011-09-01 21:20:43 +0000 (Thu, 01 Sep 2011)
Log Message:
-----------
Add helper functions

Modified Paths:
--------------
    trunk/extensions/LdapAuthentication/LdapAuthentication.php

Modified: trunk/extensions/LdapAuthentication/LdapAuthentication.php
===================================================================
--- trunk/extensions/LdapAuthentication/LdapAuthentication.php  2011-09-01 
21:17:57 UTC (rev 96042)
+++ trunk/extensions/LdapAuthentication/LdapAuthentication.php  2011-09-01 
21:20:43 UTC (rev 96043)
@@ -1105,9 +1105,8 @@
                        return $this->userInfo;
                }
 
-               $entry = @ldap_read( $this->ldapconn, $this->userdn, 
"objectclass=*", array( '*', 'memberof' ) );
-               $userInfo = @ldap_get_entries( $this->ldapconn, $entry );
-               if ( $userInfo["count"] < 1 ) {
+               $userInfo = $this->getUserInfoStateless( $this->usernn );
+               if ( is_null( $userInfo ) ) {
                        $this->fetchedUserInfo = false;
                        return;
                } else {
@@ -1116,6 +1115,32 @@
                }
        }
 
+       function getUserInfoStateless( $userdn ) {
+               // Don't fetch the same data more than once
+               // TODO: use memcached here
+
+               $entry = @ldap_read( $this->ldapconn, $userdn, "objectclass=*", 
array( '*', 'memberof' ) );
+               $userInfo = @ldap_get_entries( $this->ldapconn, $entry );
+               if ( $userInfo["count"] < 1 ) {
+                       return;
+               } else {
+                       return $userInfo;
+               }
+       }
+
+       function getSearchAttribute() {
+               global $wgLDAPSearchAttributes;
+
+               // Return the search attribute configured, mainly for use in 
other
+               // extensions
+               // TODO: make function to pull any configuration item
+               if ( isset( $wgLDAPSearchAttributes[$_SESSION['wsDomain']] ) ) {
+                       return $wgLDAPSearchAttributes[$_SESSION['wsDomain']];
+               } else {
+                       return '';
+               }
+       }
+
        /**
         * Retrieve user preferences from LDAP
         *


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to