在GWT中使用LDAP的简单登录屏幕
嗨,朋友们 我必须在GWT中使用LDAP进行简单的登录身份验证。 我用Java做过,但我不知道如何在GWT中实现同样的功能。 如果有人知道…在GWT中使用LDAP的简单登录屏幕,gwt,Gwt,嗨,朋友们 我必须在GWT中使用LDAP进行简单的登录身份验证。 我用Java做过,但我不知道如何在GWT中实现同样的功能。 如果有人知道… 我在这里粘贴了我的java源代码: package com.ldap.test; import java.util.*; import javax.naming.*; import javax.naming.directory.*; public class ldaptest { @SuppressWarnings("unchecked")
我在这里粘贴了我的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中必须做的一样。Lupo是一个基于GWT在LDAP中管理用户条目的简单工具
源代码:实现远程servlet服务,通过客户端的异步回调将用户名和凭据传递给该服务。上面的代码可以作为实现 您必须将其公开为一个文件,并从GWT代码中使用它