* WORK IN PROGRESS *
This PAM service module can be used to map given user to another based on LDAP group membership. It can work only if used as PAM accounting module.
Compile and install the .so
:
shell
cargo build --release
sudo cp target/release/libpam_groupmap.so /lib/security/pam_groupmap.so
Create the config file /etc/pam_groupmap.toml
:
```toml
[ldap]
uri = "ldaps://ldap1.example.com:636,ldaps://ldap2.example.com:636"
user = "XXX" pass = "YYY" #
#
userbasedn = "OU=people,OU=user,DC=example,DC=com" groupbasedn = "OU=db,OU=groups,DC=example,DC=com" uidattribute = "sAMAccountName" groupattribute = "memberOf"
[mappings] "dbadmin" = "dbadmin" "dbreadonly" = "dbrouser" "dbreadwrite" = "rbrwuser" ```
Make sure the config has the correct permissions:
shell
chown root:mysql /etc/pam_groupmap.toml
chmod 640 /etc/pam_groupmap.toml
Setup PAM, for example for Percona XtraDB in /etc/pam.d/mysqld
:
pam
auth requisite pam_unix.so
account requisite pam_groupmap.so /etc/pam_groupmap.toml