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.
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.