Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Critical
-
Resolution: Unresolved
-
Affects Version/s: 1.3.4
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
-
Environment:Grails 1.3.4, Windows XP, Active Directory LDAP
Description
Steps to reproduce:
1. Create an empty grails application
2. Start console and enter the following script (need to have LDAP server up and running)
import javax.naming.*
import javax.naming.ldap.*
try {
LdapContext context = new InitialLdapContext((Hashtable) [
(Context.INITIAL_CONTEXT_FACTORY): "com.sun.jndi.ldap.LdapCtxFactory",
(Context.PROVIDER_URL) : "ldap://localhost:389", // change to your LDAP server address
(Context.SECURITY_AUTHENTICATION): "simple",
(Context.SECURITY_PRINCIPAL) : "DOMAIN
invalid",
(Context.SECURITY_CREDENTIALS) : "invalid",
(Context.REFERRAL) : "follow",
(Context.BATCHSIZE) : "30"
], (Control[]) []);
println context.getDefaultInitCtx()
context.reconnect()
} catch (AuthenticationException e) {
println "NOT lOGGED IN"
}
Current result:
- this scripts shows that context.getDefaultInitCtx() returns org.springframework.mock.jndi.SimpleNamingContext
- an exception of type javax.naming.NotContextException with message "Not an instance of LdapContext" is thrown
Expected result:
- the script prints "NOT LOGGED IN" because instantiation of InitialLdapContext throws an AuthenticationException.
Remarks:
Tested against Active Directory LDAP.
Activity
- All
- Comments
- Work Log
- History
- Activity
- Git Commits
As a workaround (really ugly one) one can insert the following at the beginning of the script:
if (org.springframework.mock.jndi.SimpleNamingContextBuilder.currentContextBuilder)
org.springframework.mock.jndi.SimpleNamingContextBuilder.currentContextBuilder.deactivate()
which will deactivate the mock.
I think the real issue is that the SimpleNamingContext binds to all protocols which is OK in test environments but doing it in console is wrong as it forbids playing around with any JNDI stuff.