code: private String getUserBindDN(String username)
              throws GuacamoleException {
  
          // If a search DN is provided, search the LDAP directory for the DN
          // corresponding to the given username
          String searchBindDN = confService.getSearchBindDN();
          if (searchBindDN != null) {
  
              // Create an LDAP connection using the search account
              LDAPConnection searchConnection = ldapService.bindAs(
                  searchBindDN,
                  confService.getSearchBindPassword()
              );
  
              // Warn of failure to find
              if (searchConnection == null) {
                  logger.error("Unable to bind using search DN \"{}\"", searchBindDN);
                  return null;
              }
  
              try {
  
                  // Retrieve all DNs associated with the given username
                  List<String> userDNs = userService.getUserDNs(searchConnection, username);
                  if (userDNs.isEmpty())
                      return null;
  
                  // Warn if multiple DNs exist for the same user
                  if (userDNs.size() != 1) {
                      logger.warn("Multiple DNs possible for user \"{}\": {}", username, userDNs);
                      return null;
                  }
  
                  // Return the single possible DN
                  return userDNs.get(0);
  
              }
  
              // Always disconnect
              finally {
                  ldapService.disconnect(searchConnection);
              }
  
          }
  
          // Otherwise, derive user DN from base DN
          return userService.deriveUserDN(username);
  
      }
docs: Determines the DN which corresponds to the user having the given
  username. The DN will either be derived directly from the user base DN,
  or queried from the LDAP server, depending on how LDAP authentication
  has been configured.
  
  @param username
  The username of the user whose corresponding DN should be returned.
  
  @return
  The DN which corresponds to the user having the given username.
  
  @throws GuacamoleException
  If required properties are missing, and thus the user DN cannot be
  determined.