Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added LDAP title attribute mapping #32

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ map_username: uid
map_fullname: givenName lastName
map_email: mail
map_dn: distinguishedName
map_title: title
save_grav_user: false
store_ldap_data: false
default_access_levels:
Expand Down Expand Up @@ -94,6 +95,7 @@ default_access_levels:
|map_fullname|LDAP Attribute(s) that contains the user's full name | [default: `givenName lastName`] |
|map_email|LDAP Attribute(s) that contains the user's email address | [default: `mail`] |
|map_dn|LDAP Attribute that contains the user's DN String | [default: `distinguishedName`] |
|map_title|LDAP Attribute that contains the user's title | [default: `title`] |

### Examples

Expand Down
3 changes: 3 additions & 0 deletions login-ldap.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ public function userLoginAuthenticate(UserLoginEvent $event)
$map_fullname = $this->config->get('plugins.login-ldap.map_fullname');
$map_email = $this->config->get('plugins.login-ldap.map_email');
$map_dn = $this->config->get('plugins.login-ldap.map_dn');
$map_title = $this->config->get('plugins.login-ldap.map_title');


// Try to login via LDAP
$ldap->bind($username, $credentials['password']);
Expand Down Expand Up @@ -158,6 +160,7 @@ public function userLoginAuthenticate(UserLoginEvent $event)
$userdata['fullname'] = $this->getLDAPMappedItem($map_fullname, $ldap_data);
$userdata['email'] = $this->getLDAPMappedItem($map_email, $ldap_data);
$userdata['dn'] = $this->getLDAPMappedItem($map_dn, $ldap_data);
$userdata['title'] = $this->getLDAPMappedItem($map_title, $ldap_data);
$userdata['provider'] = 'ldap';

// Get LDAP Data if required
Expand Down
1 change: 1 addition & 0 deletions login-ldap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ map_username: uid
map_fullname: givenName lastName
map_email: mail
map_dn: distinguishedName
map_title: title

save_grav_user: false
store_ldap_data: false
Expand Down