public LDAPUserContext getUserContext(AuthenticatedUser authenticatedUser)
            throws GuacamoleException {

        if (authenticatedUser instanceof LDAPAuthenticatedUser) {

            LDAPAuthenticatedUser ldapAuthenticatedUser = (LDAPAuthenticatedUser) authenticatedUser;
            ConnectedLDAPConfiguration config = ldapAuthenticatedUser.getLDAPConfiguration();

            try {

                // Build user context by querying LDAP
                LDAPUserContext userContext = userContextProvider.get();
                userContext.init(ldapAuthenticatedUser);
                return userContext;

            }

            // Always disconnect
            finally {
                config.close();
            }
        }

        return null;

    }
Returns a UserContext object initialized with data accessible to the
given AuthenticatedUser.

@param authenticatedUser
    The AuthenticatedUser to retrieve data for.

@return
    A UserContext object initialized with data accessible to the given
    AuthenticatedUser.

@throws GuacamoleException
    If the UserContext cannot be created due to an error.
extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/AuthenticationProviderService.java