1

I have created a Java web app and deployed it on Azure App Service. In the app, we are providing users with a Login Page and upon submitting the credentials the users are authenticated using LDAP. This is working when deployed locally.

When I deploy this to Azure as WebApp, the authentication doesn't happen and the application gives an error. I am trying to authenticate like below. The LDAPContext is always returned as null in Azure.

The Authentication/Authorization settings in Azure Portal is turned OFF.

    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);
AhmedVali
  • 185
  • 2
  • 16
  • Where did you deploy the LDAP server? What distribution of LDAP server did you used? I suggested that you can use [Apache Directory Studio](https://directory.apache.org/studio/) to try to connect your LDAP server and check the issue. Any more details, please update your post. – Peter Pan Feb 01 '19 at 08:00
  • Hi Peter, I am able to connect to LDAP through Apache Studio and also it is working if I deploy it in any web app server. The issue is only when I deploy it to Azure. – AhmedVali Feb 01 '19 at 10:43
  • Any exception you got? Please check the log output via Kudu. – Peter Pan Feb 04 '19 at 06:31

1 Answers1

0
  • Server Side: Check the inbound Security rule for Which Ip address are can access the LDAP
  • If you pass the LDAP domain name in code . Try pass empty value that place
  • Try to give Auth type is Basic or Negotiate or Anonymous etc . these are in .Net Frame work same way try some other type in Java may be . So try like that

ldap://ldap.example.com - For this example.com is domain name

Rajendran S
  • 39
  • 1
  • 12