本站首页    管理页面    写新日志    退出


«August 2025»
12
3456789
10111213141516
17181920212223
24252627282930
31


公告
 本博客在此声明所有文章均为转摘,只做资料收集使用。

我的分类(专题)

日志更新

最新评论

留言板

链接

Blog信息
blog名称:
日志总数:1304
评论数量:2242
留言数量:5
访问次数:7593710
建立时间:2006年5月29日




[Apache(jakarta)]HttpClient通过ldap验证
软件技术,  电脑与网络

lhwork 发表于 2006/6/12 14:36:03

LDAP目前应用得非常广泛,在企业环境里可以供各种应用统一用户验证数据。以下是一个客户端在正常访问的时候插入验证代码,将用户提交的用户名和密码提交给ldap验证 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->HttpClient hc = new HttpClient();            GetMethod method = new GetMethod("http://www.yoursite.com/auth/your_auth.html");            String inputUserName = JOptionPane.showInputDialog("Input your User Name:");            String inputPassWord = JOptionPane.showInputDialog("Input your password:");            UsernamePasswordCredentials upc = new UsernamePasswordCredentials(inputUserName, inputPassWord);            hc.getState().setCredentials(null, null, upc);            int status = hc.executeMethod(method);            method.releaseConnection();            if(status == 200)            {                System.out.println("login successful!");                //do your business things            } else            {                System.out.println("Login failed!  Please check your userName and Password!");            } http://www.yoursite.com/auth/your_auth.html如果直接访问会弹出对话框让你输入用户名密码  


阅读全文(3370) | 回复(0) | 编辑 | 精华
 



发表评论:
昵称:
密码:
主页:
标题:
验证码:  (不区分大小写,请仔细填写,输错需重写评论内容!)



站点首页 | 联系我们 | 博客注册 | 博客登陆

Sponsored By W3CHINA
W3CHINA Blog 0.8 Processed in 0.059 second(s), page refreshed 144763361 times.
《全国人大常委会关于维护互联网安全的决定》  《计算机信息网络国际联网安全保护管理办法》
苏ICP备05006046号