Skip to content

Manage Group Memberships

Overview

At checkout the broker adds the requesting user to an OpenLDAP group; at checkin it removes them. Two Bash scripts use standard LDAP utilities (ldapsearch, ldapmodify) and ignore any email suffix on the username. Groups use the posixGroup objectClass.

Before You Begin

Configuration

Set these in the scripts (or via env vars / a secret store — do not hardcode in production):

VariableExample
LDAP_SERVERldap://localhost
BASE_DNdc=example,dc=com
BIND_DNcn=admin,dc=example,dc=com
BIND_PASSWORDbind password

Checkout / Checkin

Full scripts: add_user_to_group.sh · remove_user_from_group.sh

# checkout — add member
ldapmodify -x -H "$LDAP_SERVER" -D "$BIND_DN" -w "$BIND_PASSWORD" <<EOF
dn: cn=$GROUP,ou=groups,$BASE_DN
changetype: modify
add: memberUid
memberUid: $USER
EOF

# checkin — delete member (remove_user_from_group.sh) uses: delete memberUid

Configure in Britive

Create the permission

Resource Manager → Resource Type Permissions → New Permission. Language = Shell. Paste the add script as Checkout and the remove script as Checkin. Declare the LDAP connection variables and GROUP; the user is system-defined.

Create a profile and policy

Create a profile (e.g. 4h), set GROUP, add the permission, and add a policy assigning members by tag.

Verify

ldapsearch -x -H "$LDAP_SERVER" -b "cn=<group>,ou=groups,$BASE_DN" memberUid
# the user's uid appears during checkout, gone after checkin

Troubleshoot

SymptomCauseFix
“user does not exist”User not under ou=usersConfirm the user DN and BASE_DN
Group modify failsGroup missing or wrong objectClassEnsure a posixGroup exists at cn=<group>,ou=groups
Bind errorWrong BIND_DN/BIND_PASSWORDVerify bind credentials; prefer LDAPS in production

Next Steps

Last updated on