protected String getUsernameFromAttributes(Attributes directoryAttributes)
      throws NamingException {
    String username =
        DirectoryAttributeRetriever.getValueFromAttributes(
            ldapPropertiesMapper.getUserNameAttribute(), directoryAttributes);

    if (username == null) {
      logger.fatal(
          "The following record does not have a username: "******"Unable to find the username of the principal.");
    }

    return username;
  }