diff --git a/cas_attributes.admin.inc b/cas_attributes.admin.inc
index 1efec81..c3879ff 100644
--- a/cas_attributes.admin.inc
+++ b/cas_attributes.admin.inc
@@ -119,6 +119,22 @@ function cas_attributes_admin_settings() {
'#default_value' => $managed_roles['mapping'],
);
+ if (module_exists('cas_ldap')) {
+ $links = array(
+ '@cas_attr' => url('admin/config/people/cas/attributes/cas'),
+ '@ldap_attr' => url('admin/config/people/cas/attributes/ldap')
+ );
+ $form['cas_attributes_roles']['cas_attributes_roles_cas_or_ldap'] = array(
+ '#type' => 'radios',
+ '#title' => t('CAS or LDAP attributes?'),
+ '#description' => t('Specify if you are matching roles based on ' .
+ 'CAS attributes or LDAP attributes. ' .
+ 'Both cannot be supported at once due to namespace collisions with the attribute names.', $links),
+ '#options' => array('cas' => t('CAS'), 'ldap' => t('LDAP')),
+ '#default_value' => variable_get('cas_attributes_roles_cas_or_ldap', 'cas'),
+ );
+ }
+
$form['token_tree'] = array(
'#theme' => 'token_tree',
'#token_types' => array('cas'),
diff --git a/cas_attributes.module b/cas_attributes.module
index cdff639..d7c1984 100644
--- a/cas_attributes.module
+++ b/cas_attributes.module
@@ -83,7 +83,13 @@ function cas_attributes_cas_user_presave(&$edit, $account) {
// Make sure there are attributes to check.
if (!empty($cas_attributes['roles']['mapping'])) {
// Get the users attributes.
- $user_attributes = cas_phpcas_attributes($data['cas']);
+ $attribute_matching_type = variable_get('cas_attributes_roles_cas_or_ldap', 'cas');
+ if ($attribute_matching_type == 'cas') {
+ $user_attributes = cas_phpcas_attributes($data['cas']);
+ }
+ elseif (module_exists('cas_ldap') && $attribute_matching_type == 'ldap') {
+ $user_attributes = cas_ldap_attributes($data['cas']);
+ }
// Allow other modules to manipulate the attribute values.
// Can't use module_invoke_all() because we need to pass byref.
$arguments = array(&$user_attributes);
@@ -92,9 +98,9 @@ function cas_attributes_cas_user_presave(&$edit, $account) {
call_user_func_array($function, $arguments);
}
- // Build all the attirbutes to check.
+ // Build all the attributes to check.
$cas_user_roles = array();
- $attributes_to_check = explode("\n", $cas_attributes['roles']['mapping']);
+ $attributes_to_check = preg_split("#\n|\r#", $cas_attributes['roles']['mapping']);
foreach ($attributes_to_check as $attribute) {
if (!empty($user_attributes[$attribute])) {
if (is_array($user_attributes[$attribute])) {