Hi to all,
I'm a new user.
I have a lot of problem to create a Java code to do a login action and get all from into a LDAP.
It's one week and I found only yesterday a Java code to do a login
I must use inject proprieties because I don't know how and when the LDAP will change.Code:public List<User> login(String userName, String password) throws LdapException { List<User> list = null; if (!ldapTemplate.authenticate(logInFilterBase, "(cn=" + userName + ")", password)) { throw new GseLdapException("Error: user not authenticated!"); } else { AndFilter filter = new AndFilter(); filter.and(new EqualsFilter("objectclass", "myPersonDef")).and(new EqualsFilter("cn", userName)); list = ldapTemplate.search(DistinguishedName.EMPTY_PATH, filter.encode(), new AttributesMapper() { public Object mapFromAttributes(Attributes atrbts) throws NamingException { throw new UnsupportedOperationException("Not supported yet."); } }); System.out.println("list: " + list.size()); System.out.println("first element: " + list.get(0).getFirstUserInfo()); } return list; }
To get all user info I must have an injection from servlet-context.xml to create an AttributeMapper, like I do with te ldapTemplate:
Anyone can help me?Code:<bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate"> <property name="contextSource" ref="contextSource" /> </bean> <bean id="ldapOperationsBean" class="com.palla.ldap.operation.impl.LdapOperationsImpl" > <property name="ldapTemplate" ref="ldapTemplate"/> <property name="logInFilterBase" value="dc=example,dc=com"/> </bean>
Ask me all you want
P.S.
I read this page http://static.springsource.org/sprin...tml/index.html and other manual/tutorial, but if you give me other example is better because I had problem with some code get from the page before.



Reply With Quote