UniTime ActiveDirectory Authentication #128
-
I have setup UniTime in Eclipse on Windows and using blank-data database schema. The application is logging in successfully when I use admin as username and passwrod. But I am encountering "Authentication failed: Login Failure: all modules ignored." error when I try to login using LDAP credentials. As far as I could understand from the instructions on https://help.unitime.org/LDAP, I have added line "unitime.spring.context.security=securityContextLDAP.xml" in Tomcat's catalina.properties file. I have also made test application to check if LDAP is being authenticated on my machine and the test application is successfully authenticating LDAP users. Can anyone help me understand what I am missing? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 1 reply
-
Setting up the LDAP authentication can be tricky. If you set the logging level for org.springframework.security.ldap to DEBUG, what messages/errors are you getting? Do you see any errors in Tomcat's log? How do the parameters in the securityContextLDAP.xml match with what you have in your test application? Also, please note that UniTime needs an external id of an LDAP authenticated user. If you do not have such an attribute (typically a university id), you can use the uid (or cn, or email for instance) instead. However, for the user to get a role, this external id must match the external id in the Timetable Magers, Instructors, Students, or Advisors. Authenticated users that do not have a special UniTime-role will get the No Role role (e.g., a user does not need a UniTime role to see a class schedule or request an event). |
Beta Was this translation helpful? Give feedback.
-
I think that making the same change would mean updating the
Where |
Beta Was this translation helpful? Give feedback.
-
Owing to my ignorance, I couldn't completely decipher your answer and have been trying different things. Currently I am stuck in the following: When the control goes in this function: org.springframework.security.ldap.authentication.BindAuthenticator
private DirContextOperations bindWithDn(String userDnStr, String username, String password, Attributes attrs) {
BaseLdapPathContextSource ctxSource = (BaseLdapPathContextSource) getContextSource();
DistinguishedName userDn = new DistinguishedName(userDnStr);
DistinguishedName fullDn = new DistinguishedName(userDn);
fullDn.prepend(ctxSource.getBaseLdapPath());
logger.debug(LogMessage.format("Attempting to bind as %s", fullDn));
DirContext ctx = null;
try {
ctx = getContextSource().getContext(fullDn.toString(), password);
// Check for password policy control
PasswordPolicyControl ppolicy = PasswordPolicyControlExtractor.extractControl(ctx);
logger.debug("Retrieving attributes...");
if (attrs == null || attrs.size() == 0) {
attrs = ctx.getAttributes(userDn, getUserAttributes());
}
DirContextAdapter result = new DirContextAdapter(attrs, userDn, ctxSource.getBaseLdapPath());
if (ppolicy != null) {
result.setAttributeValue(ppolicy.getID(), ppolicy);
}
return result;
}
catch (NamingException ex) {
// This will be thrown if an invalid user name is used and the method may
// be called multiple times to try different names, so we trap the exception
// unless a subclass wishes to implement more specialized behaviour.
if ((ex instanceof org.springframework.ldap.AuthenticationException)
|| (ex instanceof org.springframework.ldap.OperationNotSupportedException)) {
handleBindException(userDnStr, username, ex);
}
else {
throw ex;
}
}
catch (javax.naming.NamingException ex) {
throw LdapUtils.convertLdapException(ex);
}
finally {
LdapUtils.closeContext(ctx);
}
return null;
} I have I was wondering if you can guide me any further because I have tried myself a lot but nothing is working out. |
Beta Was this translation helpful? Give feedback.
-
Ok, if the I did set up LDAP authentication against an Active Directory for an institution in Canada once, and we had to use a search filter with
We have also updated the ldap-server element, filling in manager-dn and manager-password.
And they had the following properties set:
But they have used their This is pretty much the extent of my knowledge of LDAP authentication when it comes to Active Directory. |
Beta Was this translation helpful? Give feedback.
-
It resolved the authentication error and UniTime is now successfully authenticating from ActiveDirectory. Thanks you for the prompt responses and helpful suggestions regarding the errors I was encountering. Your support and assistance always helped a lot and this time too it resolved the issue. I admire your dedication in maintaining the UniTime. Your work undoubtedly helped many users like myself. Thank you once again for your help and support. |
Beta Was this translation helpful? Give feedback.
Ok, if the
userDnStr
is onlysAMAccountName=MyUsername
, the search base either has to be the rest (CN=MyUsername,OU=MyDepartment,OU=MyEmployeeType,OU=Active Employees,OU=Entire Org,DC=org,DC=net
) or youw would need to use a search filter with(sAMAccountName={0})
instead of the user DN matching.I did set up LDAP authentication against an Active Directory for an institution in Canada once, and we had to use a search filter with
(sAMAccountName={0})
instead of the user DN matching (they also had different trees for faculty, students, and for staff). The spring security configuration was changed as follows (the ldapAuthProvider bean):