I need to access a 开发者_开发技巧website and get information through it. I need to pass through an ldap authentication in ie for this.i just know the ip of the LDAP server.I thought of doing this through JNDI but still I don't know how to get the parameters of the server for authentication. Could someone tell me how to pass on the authentication connecting to this server.
With a rather vague question I am just going to point you to Spring LDAP which is easy to use and has good documentation on all things related to LDAP and Java.
You can't 'find' it, and you can't 'get' the server parameters for authentication either. You have to know it all in advance. You can make this stuff configuration parameters of your Web-app. In Tomcat you can define an LDAP Resource in context.xml and support it via an LdapObectFactory as described in the Tomcat Resource documentation.
you "need" the information about the server's (host) ip or name and the base DN of the directory where you entries are. you aren't going to find this anywhere - these will be specified by the server that you are trying to connect to.
This is how you generally authenticate against a ldap server:
- Get login (or email) and password from user.
- Bind to the LDAP server anonymously (or using a service account if anonymous binds are disabled)
- Search the directory using an appropriate filter to identify the record for the specific login name provided.
- If one and only one entry is returned, that is the entry you want - get the DN of the entry. (If zero, or more than one entries are returned, return "no such user")
- Re-bind to the LDAP directory using the DN returned in step 4 and the password from step 1
- If the LDAP server allows the bind, the login is successful. Otherwise, return "invalid password"
精彩评论