jtblin / go-ldap-client

Simple ldap client to authenticate, retrieve basic information and groups for a user.
Other
261 stars 90 forks source link

Bind before getting groups of user #18

Open bk2204 opened 5 years ago

bk2204 commented 5 years ago

In some cases, we will not want to authenticate a user, only get their groups, such as when performing access control for a user authenticated elsewhere. In such a case, we will not have bound the connection to the LDAP server using the read-only user, so if the LDAP server does not allow unauthenticated access, our GetGroupsOfUser call will fail.

Ensure we bind using the read-only user, if one is provided, before trying to fetch the user's groups.