LDAP Serach Error - NotContextException

Avatar

Avatar
Validate 1
Level 2
monikaa6
Level 2

Likes

12 likes

Total Posts

37 posts

Correct reply

3 solutions
Top badges earned
Validate 1
Give Back 3
Give Back
Ignite 1
Boost 5
View profile

Avatar
Validate 1
Level 2
monikaa6
Level 2

Likes

12 likes

Total Posts

37 posts

Correct reply

3 solutions
Top badges earned
Validate 1
Give Back 3
Give Back
Ignite 1
Boost 5
View profile
monikaa6
Level 2

02-11-2016

Hi All,

We are upgarding from CQ5.6.1 to AEM 6.2. In the earlier version we had a code that search the content of Ldap using javax.naming.directory* classes.

Like the way

DirContext ctx = new InitialDirContext(env); //Creating context NamingEnumeration<SearchResult> ldapResults = ctx.search(base.get(), filter, sc); //Calling search method with arguments, this line throws Exception

When we are running the same code in AEM 6.2, getting the error.

javax.naming.NotContextException: Not an instance of DirContext at javax.naming.directory.InitialDirContext.getURLOrDefaultInitDirCtx(InitialDirContext.java:111) at javax.naming.directory.InitialDirContext.search(InitialDirContext.java:267)

Any one faced this issue? The only difference I know is that in Cq5.6.1, we used to do the LDAP configs at server level, in AEm 6.2 they are available in OSGI configs.

Note:- We are defaining the LDAP enviornment varaibles in the Java class as well where we are getting the exception

Thanks

Monika

View Entire Topic

Avatar

Avatar
Boost 50
Level 10
Sham_HC
Level 10

Likes

161 likes

Total Posts

2,114 posts

Correct reply

1,204 solutions
Top badges earned
Boost 50
Boost 5
Boost 3
Boost 25
Boost 100
View profile

Avatar
Boost 50
Level 10
Sham_HC
Level 10

Likes

161 likes

Total Posts

2,114 posts

Correct reply

1,204 solutions
Top badges earned
Boost 50
Boost 5
Boost 3
Boost 25
Boost 100
View profile
Sham_HC
Level 10

02-11-2016

Hi Monika,

Osgi is an JNDI implementation does not interact well with factory DirContext or LdapContext for casting it back. You can find couple of issue in web on this with various osgi providers. To over come this make use of enhanced LDAP API which replaces JNDI and the existing LDAP API like "schema aware" API with convenient ways to access any LDAP server.

 

Thanks,