posts - 66,  comments - 40,  trackbacks - 0
1)先用hashTable初始化ldap用到的参数。
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL,"ldap://192.***.***.***:portNumber(389 is defualt)");
env.put(Context.SECURITY_PRINCIPAL,userID+"yourDomain(@***.com)");//
env.put(Context.SECURITY_CREDENTIALS, pass);
userID 和 pass就是登录域的账号。不要用全称。因为你在上面用到了域名。
2)开始验证。通过try..catch来判断用户的合法性。
try{
LdapContext ctx = new InitialLdapContext(env, null);
System.out.println("Succeess");
} catch (Exception e) {
if (e.getMessage().indexOf("775") > = 0) {
System.out.println("你的账号被锁了。");
}else {
System.out.println("Invalid User");
}
}
posted on 2007-08-22 11:58 happytian 阅读(397) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航:
 
<2007年8月>
2930311234
567891011
12131415161718
19202122232425
2627282930311
2345678

Welcome here, my friend!

常用链接

留言簿(12)

随笔档案(66)

文章分类

文章档案(63)

web

最新随笔

搜索

  •  

积分与排名

  • 积分 - 87862
  • 排名 - 645

最新评论

阅读排行榜

评论排行榜