免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3737 | 回复: 4
打印 上一主题 下一主题

请教大家一个关于C#和ldap的认证关系 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-05-26 10:36 |只看该作者 |倒序浏览
请教大家一个问题,我现在的需求是,以后用C#写的程序以后不通过数据库验证用户信息,而是把用户信息存放在ldap服务器中,我现在用的是novell的edirectory,请教大家程序该怎么写,以前没怎么研究过。知道的TX最后能给源代码,呵呵,谢谢

论坛徽章:
0
2 [报告]
发表于 2010-05-26 10:37 |只看该作者
回复 1# talentqiu


    我的源码如下,不过貌似还有点问题,请高手帮忙看下


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Novell.Directory.Ldap;



namespace LDAP_TEST
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            
            string username = textBox1.Text.Trim();
            string password = textBox2.Text.Trim();

            //LDAP服务器路径
            string path = "LDAP://172.18.95.136:389/cn=zhangsan,ou=test,ou=sap,o=group";
            System.DirectoryServices.DirectoryEntry de = new System.DirectoryServices.DirectoryEntry(
                path, username, password, System.DirectoryServices.AuthenticationTypes.ServerBind);
            
         
            try
            {
                System.DirectoryServices.DirectorySearcher search = new System.DirectoryServices.DirectorySearcher();
                string guid = de.Guid.ToString();
                label3.Text = guid;
                //return true;
            }
            catch(Exception error)
            {
                //return false;
                label3.Text = error.Message;
            }
        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }
    }
}

论坛徽章:
0
3 [报告]
发表于 2010-05-27 09:40 |只看该作者

论坛徽章:
0
4 [报告]
发表于 2010-05-28 12:34 |只看该作者
提示: 作者被禁止或删除 内容自动屏蔽

论坛徽章:
0
5 [报告]
发表于 2010-05-31 11:27 |只看该作者
再来顶下,呵呵,知道的同学讲下哈
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP