【发布时间】:2019-06-22 10:13:26
【问题描述】:
我创建了一个 Java Web 应用并将其部署在 Azure 应用服务上。在应用程序中,我们为用户提供登录页面,并在提交凭据后使用 LDAP 对用户进行身份验证。 这在本地部署时有效。
当我将它作为 WebApp 部署到 Azure 时,不会发生身份验证并且应用程序会出错。我正在尝试像下面这样进行身份验证。 LDAPContext 在 Azure 中始终返回为 null。
Azure 门户中的身份验证/授权设置已关闭。
LdapContext ctx = null;
String dn= "uid=" + username + ",ou=users,ou=xxxx,o=xxxxx";
String ldapURL = "ldap://ldap.example.com:389";
Hashtable<String, String> environment =new Hashtable<String, String>();
environment.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
environment.put(Context.PROVIDER_URL, ldapURL);
environment.put(Context.SECURITY_AUTHENTICATION, "simple");
environment.put(Context.SECURITY_PRINCIPAL, dn);
environment.put(Context.SECURITY_CREDENTIALS, password);
ctx = new InitialLdapContext(environment,null);
【问题讨论】:
-
您在哪里部署了 LDAP 服务器?你使用了什么分布的 LDAP 服务器?我建议您可以使用Apache Directory Studio 尝试连接您的 LDAP 服务器并检查问题。更多详细信息,请更新您的帖子。
-
嗨彼得,我可以通过 Apache Studio 连接到 LDAP,如果我将它部署在任何 Web 应用程序服务器中,它也可以工作。只有当我将它部署到 Azure 时才会出现问题。
-
你有什么例外吗?请通过 Kudu 查看日志输出。
标签: azure azure-active-directory azure-web-app-service azure-java-sdk