This discussion is archived
2 Replies Latest reply: Jan 21, 2013 4:48 AM by Frank Nimphius RSS

Unable to authenticate using LDAP

975391 Newbie
Currently Being Moderated
Hello all,

I am creating a native android mobile application using JDeveloper and require LDAP binding for authentication. But when I am writing the method for it, an error is occuring which says that *"Type DirContext not found"* . Even the import statement *"import;"* is also giving the same error. Please help.

The code I have written is as follows :

*public static DirContext getDirContext(String pinUid, String pinPwd) {*

DirContext ctx1 = null;
String LdapUrl = "ldap://";
String LdapPort = "3060";
String username = "cn=" + pinUid + ",cn=Users,dc=tcs,dc=com";
System.out.println("username: " + username);
*try {*
Hashtable env = new Hashtable(5);
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, LdapUrl + ":" + LdapPort);
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL, username);
env.put(Context.SECURITY_CREDENTIALS, pinPwd);

System.out.println("UNAME" + username);
System.out.println("PWD" + pinPwd);

ctx1 = new InitialDirContext(env);
System.out.println("The directory context has been created");
flag = 1;
*} catch (Exception e) {*
System.out.println("Failed to create the directory context" + e.toString());
flag = 0;
System.out.println("Flag is" + flag);

return ctx1;

Thanks in advance.
  • 1. Re: Unable to authenticate using LDAP
    user404 Pro
    Currently Being Moderated
    I'm not sure this suits your use case but:
    You can configure your LDAP in the WLS (in the security realm).
    Then you can use ADF security to authenticate against the WLS, who on his part authenticates against your LDAP. (so you will need an normal application, more info : )
  • 2. Re: Unable to authenticate using LDAP
    Frank Nimphius Employee ACE
    Currently Being Moderated

    ADF Mobile supports JavaME 1.4 CDC. This version dos not support javax.naming,* package. So as suggested, use LDAP for WLS domain authentification and use feature security for autentication. This should work



  • Correct Answers - 10 points
  • Helpful Answers - 5 points