xperseguers / t3ext-ig_ldap_sso_auth

TYPO3 Extension ig_ldap_sso_auth. This extension provides LDAP and SSO support for TYPO3.
https://extensions.typo3.org/extension/ig_ldap_sso_auth
27 stars 68 forks source link

Ajax Import fails due to missing attributes #15

Closed pixelbrackets closed 5 years ago

pixelbrackets commented 6 years ago

Enviroment

TYPO3 7.6 ig_ldap_sso_auth 3.3.0

The backend module offers a list of LDAP users & groups, which may be imported into the CMS manually by clicking a button.

Expected behaviour

Fetch user data from LDAP and store it into a user record in TYPO3.

Actual behaviour

Upon clicking the »Import« button the request starts, but does not import the user.

Reason

The LDAP of my installation does not return all attributes by default. Instead I need to pass a list of attributes to the search request. This list is used in the »search« action, but not in the »import« action of the module.

https://github.com/xperseguers/t3ext-ig_ldap_sso_auth/blob/master/Classes/Controller/ModuleController.php#L346

https://github.com/xperseguers/t3ext-ig_ldap_sso_auth/blob/master/Classes/Controller/ModuleController.php#L437

In my case the roles of the users are stored in some arbitrary field in LDAP. In need to pass this fieldname as attribute to the search method, otherwise a dataset without the fieldname is returned. This causes the mapping of LDAP fields to TYPO3 fields to fail, because some fields are missing.

Solution Ideas

Add the $attributes = Configuration::getLdapAttributes($config[$key]['mapping']); method, just as in search (https://github.com/xperseguers/t3ext-ig_ldap_sso_auth/blob/master/Classes/Controller/ModuleController.php#L220).

(Not tested yet)

pixelbrackets commented 6 years ago

Possible reason why this method passes an empty list:

https://github.com/xperseguers/t3ext-ig_ldap_sso_auth/blob/master/Classes/Library/Authentication.php#L253-L255

// Restricting the list of returned attributes sometimes makes the ldap_search() method issue a PHP warning: // Warning: ldap_search(): Array initialization wrong // so we just ask for every attribute ("true" below)!