- 论坛徽章:
- 0
|
回复 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)
{
}
}
} |
|