Skip to content
Snippets Groups Projects
Unverified Commit 008d2de8 authored by Tim van Dijen's avatar Tim van Dijen Committed by GitHub
Browse files

Code quality

parent 2c0733cf
No related branches found
No related tags found
No related merge requests found
...@@ -86,7 +86,6 @@ class sspmod_ldap_Auth_Process_AttributeAddUsersGroups extends sspmod_ldap_Auth_ ...@@ -86,7 +86,6 @@ class sspmod_ldap_Auth_Process_AttributeAddUsersGroups extends sspmod_ldap_Auth_
// Based on the directory service, search LDAP for groups // Based on the directory service, search LDAP for groups
// If any attributes are needed, prepare them before calling search method // If any attributes are needed, prepare them before calling search method
switch ($this->product) { switch ($this->product) {
case 'ACTIVEDIRECTORY': case 'ACTIVEDIRECTORY':
// Log the AD specific search // Log the AD specific search
...@@ -96,10 +95,7 @@ class sspmod_ldap_Auth_Process_AttributeAddUsersGroups extends sspmod_ldap_Auth_ ...@@ -96,10 +95,7 @@ class sspmod_ldap_Auth_Process_AttributeAddUsersGroups extends sspmod_ldap_Auth_
// Make sure the defined dn attribute exists // Make sure the defined dn attribute exists
if (!isset($attributes[$map['dn']])) { if (!isset($attributes[$map['dn']])) {
throw new SimpleSAML_Error_Exception( $this->throwAttributeNotDefined('DN', $map['dn'], implode(', ', array_keys($attributes)));
$this->title . 'The DN attribute [' . $map['dn'] .
'] is not defined in the users Attributes: ' . implode(', ', array_keys($attributes))
);
} }
// DN attribute must have a value // DN attribute must have a value
...@@ -113,7 +109,7 @@ class sspmod_ldap_Auth_Process_AttributeAddUsersGroups extends sspmod_ldap_Auth_ ...@@ -113,7 +109,7 @@ class sspmod_ldap_Auth_Process_AttributeAddUsersGroups extends sspmod_ldap_Auth_
// Pass to the AD specific search // Pass to the AD specific search
$groups = $this->searchActiveDirectory($attributes[$map['dn']][0]); $groups = $this->searchActiveDirectory($attributes[$map['dn']][0]);
break; break;
case 'OPENLDAP': case 'OPENLDAP':
// Log the OpenLDAP specific search // Log the OpenLDAP specific search
SimpleSAML\Logger::debug( SimpleSAML\Logger::debug(
...@@ -138,7 +134,6 @@ class sspmod_ldap_Auth_Process_AttributeAddUsersGroups extends sspmod_ldap_Auth_ ...@@ -138,7 +134,6 @@ class sspmod_ldap_Auth_Process_AttributeAddUsersGroups extends sspmod_ldap_Auth_
break; break;
default: default:
// Log the general search // Log the general search
SimpleSAML\Logger::debug( SimpleSAML\Logger::debug(
$this->title . 'Searching LDAP using the default search method.' $this->title . 'Searching LDAP using the default search method.'
...@@ -146,10 +141,7 @@ class sspmod_ldap_Auth_Process_AttributeAddUsersGroups extends sspmod_ldap_Auth_ ...@@ -146,10 +141,7 @@ class sspmod_ldap_Auth_Process_AttributeAddUsersGroups extends sspmod_ldap_Auth_
// Make sure the defined memberOf attribute exists // Make sure the defined memberOf attribute exists
if (!isset($attributes[$map['memberof']])) { if (!isset($attributes[$map['memberof']])) {
throw new SimpleSAML_Error_Exception( $this->throwAttributeNotDefined('memberof', $map['memberof'], implode(', ', array_keys($attributes)));
$this->title . 'The memberof attribute [' . $map['memberof'] .
'] is not defined in the users Attributes: ' . implode(', ', array_keys($attributes))
);
} }
// MemberOf must be an array of group DN's // MemberOf must be an array of group DN's
...@@ -171,6 +163,11 @@ class sspmod_ldap_Auth_Process_AttributeAddUsersGroups extends sspmod_ldap_Auth_ ...@@ -171,6 +163,11 @@ class sspmod_ldap_Auth_Process_AttributeAddUsersGroups extends sspmod_ldap_Auth_
return $groups; return $groups;
} }
protected function throwAttributeNotDefined($attr, $attr_value, $attributes)
{
throw new SimpleSAML_Error_Exception($this->title . 'The ' . $attr . ' attribute [' . $attr_value .
'] is not defined in the user\'s Attributes: ' . $attributes);
}
/** /**
* Looks for groups from the list of DN's passed. Also * Looks for groups from the list of DN's passed. Also
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment