From: <axe...@us...> - 2010-05-10 03:34:57
|
Revision: 108 http://wpmu-ldap.svn.sourceforge.net/wpmu-ldap/?rev=108&view=rev Author: axelseaa Date: 2010-05-10 03:34:51 +0000 (Mon, 10 May 2010) Log Message: ----------- a few changes based on ken's feedback - thanks\! Modified Paths: -------------- trunk/ldap/lib/ldap_core.php trunk/ldap/lib/ldap_ro.php trunk/ldap/lib/wpmu_ldap.functions.php Modified: trunk/ldap/lib/ldap_core.php =================================================================== --- trunk/ldap/lib/ldap_core.php 2010-05-06 11:35:00 UTC (rev 107) +++ trunk/ldap/lib/ldap_core.php 2010-05-10 03:34:51 UTC (rev 108) @@ -200,13 +200,17 @@ function checkGroup($userDN,$groups){ //Make sure we're connected - we're not when this is called from the admin side if (!$this->connection_handle) { - $this->connect(); + $this->dock(); } if (empty($groups)) return LDAP_GROUP_NOT_SET; // Get Groups - $this->SetSearchCriteria("(&(".get_site_option('ldapAttributeMember',LDAP_DEFAULT_ATTRIBUTE_MEMBER)."=$userDN)(objectclass=".get_site_option('ldapAttributeGroupObjectclass',LDAP_DEFAULT_ATTRIBUTE_GROUP_OBJECTCLASS)."))", array(get_site_option('ldapAttributeDN',LDAP_DEFAULT_ATTRIBUTE_DN))); + $attributes_to_get = array(get_site_option('ldapAttributeDN',LDAP_DEFAULT_ATTRIBUTE_DN)); + $search_filter = "(".get_site_option('ldapAttributeMember',LDAP_DEFAULT_ATTRIBUTE_MEMBER)."=$userDN)"; + $search_filter .= "(objectclass=".get_site_option('ldapAttributeGroupObjectclass',LDAP_DEFAULT_ATTRIBUTE_GROUP_OBJECTCLASS)."))"; + $this->SetSearchCriteria("(&(".get_site_option('ldapAttributeMember',LDAP_DEFAULT_ATTRIBUTE_MEMBER)."=$userDN)(objectclass=".get_site_option('ldapAttributeGroupObjectclass',LDAP_DEFAULT_ATTRIBUTE_GROUP_OBJECTCLASS)."))", $attributes_to_get); + $this->Search(); $results = ldap_get_entries($this->connection_handle, $this->search_result); // Check Groups Modified: trunk/ldap/lib/ldap_ro.php =================================================================== --- trunk/ldap/lib/ldap_ro.php 2010-05-06 11:35:00 UTC (rev 107) +++ trunk/ldap/lib/ldap_ro.php 2010-05-10 03:34:51 UTC (rev 108) @@ -76,8 +76,7 @@ // Default Catch $return = LDAP_OK; - } - else { + } else { if ($this->GetErrorNumber() == 49) { $return = LDAP_ERROR_WRONG_PASSWORD; } @@ -160,10 +159,21 @@ $data[LDAP_INDEX_GIVEN_NAME] = $this->GetLDAPInfo (LDAP_INDEX_GIVEN_NAME); $data[LDAP_INDEX_SURNAME] = $this->GetLDAPInfo (LDAP_INDEX_SURNAME); $data[LDAP_INDEX_PHONE] = $this->GetLDAPInfo (LDAP_INDEX_PHONE); + + // If deny group set and user found, return + $deny = $this->checkGroup($user_data[LDAP_INDEX_DN],wpmuLdapGroupsGet(array('siteoption' => 'ldapGroupDenyLogin'))); + if ($deny == LDAP_IN_GROUP) return LDAP_ERROR_DENIED_GROUP; + + // If allow group set and user found, + $allow = $this->checkGroup($user_data[LDAP_INDEX_DN],wpmuLdapGroupsGet(array('siteoption' => 'ldapGroupAllowLogin'))); + if ($allow == LDAP_IN_GROUP) return LDAP_OK; // found in group + if ($allow == LDAP_ERROR_NOT_IN_GROUP) return LDAP_ERROR_ACCESS_GROUP; // not in group + + // Default Catch + return LDAP_OK; } else { $data = null; } - return LDAP_OK; } function GetEmailList ($in_email_list_name, &$emails, &$dns) { @@ -203,4 +213,3 @@ return true; } } -?> Modified: trunk/ldap/lib/wpmu_ldap.functions.php =================================================================== --- trunk/ldap/lib/wpmu_ldap.functions.php 2010-05-06 11:35:00 UTC (rev 107) +++ trunk/ldap/lib/wpmu_ldap.functions.php 2010-05-10 03:34:51 UTC (rev 108) @@ -192,13 +192,14 @@ $userDataArray = null; if ($server->DoSearchUsername($in_username, $attributes_to_get, $userDataArray) == LDAP_OK) { - if (!empty($userDataArray)) { - if ($server->checkGroup($userDataArray[LDAP_INDEX_DN]) == 0) { - return true; - } else { - return false; - } - } + return true; +# if (!empty($userDataArray)) { +# if ($server->checkGroup($userDataArray[LDAP_INDEX_DN]) == 0) { +# return true; +# } else { +# return false; +# } +# } } return false; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |