嗨,朋友们,
我必须在GWT中使用LDAP进行简单登录身份验证。 我在Java中做过。但我不知道在GWT中实现相同的功能。 如果有人知道,请帮帮我... 我在这里粘贴了我的java源代码:
package com.ldap.test;
import java.util.*;
import javax.naming.*;
import javax.naming.directory.*;
public class ldaptest {
@SuppressWarnings("unchecked")
public static void main(String[] args) {
try {
@SuppressWarnings("rawtypes")
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL,
"LDAP://localhost:389"); //replace with your server URL/IP
//only DIGEST-MD5 works with our Windows Active Directory
env.put(Context.SECURITY_AUTHENTICATION,
"Simple"); //No other SALS worked with me
env.put(Context.SECURITY_PRINCIPAL,
"uid=karthick,ou=users,ou=system"); // specify the username ONLY to let Microsoft Happy
env.put(Context.SECURITY_CREDENTIALS, "karthick"); //the password
DirContext ctx = new InitialDirContext(env);
ctx.close();
enter code here
} catch(NamingException ne) {
System.out.println("Error authenticating user:");
System.out.println(ne.getMessage());
return;
}
//if no exception, the user is already authenticated.
System.out.println("OK, successfully authenticating user");
}
}
//我必须在GWT中做同样的事情。
答案 0 :(得分:1)
实现远程servlet服务,通过客户端的异步回调将用户名和凭据传递给服务。上面的代码可以作为实现。
答案 1 :(得分:0)
Lupo,一种基于GWT管理LDAP中用户条目的简单工具。