zoukankan
html css js c++ java
c#活动目录操作
添加引用 System.DirectoryServices
导入命名空间 using System.DirectoryServices;
srvip
=
"
192.168.1.1
"
;
dn
=
"
DC=l,DC=com
"
;
user
=
@"
administrator
"
;
pwd
=
"
123
"
;
DirectoryEntry de;
de
=
new
DirectoryEntry(
"
LDAP://
"
+
srvip
+
"
/
"
+
dn, user, pwd);
DirectorySearcher sr
=
new
DirectorySearcher(de,
"
(userPrincipalName=
"
+
logname
+
"
)
"
); //要括起来
string
path
=
sr.FindOne().Properties[
"
distinguishedName
"
][
0
].ToString();
CN 用户名
OU 组织
DC 域控制器
userPrincipalName 登录名
Code
string
srvip
=
textBox2.Text;
//
"192.168.0.21";
string
dn
=
textBox3.Text;
//
"DC=DEMO,DC=com";
string
user
=
textBox4.Text;
//
@"administrator";
string
pwd
=
textBox5.Text;
//
"123456";
DirectoryEntry de;
de
=
new
DirectoryEntry(
"
LDAP://
"
+
srvip
+
"
/
"
+
dn, user, pwd);
DirectorySearcher sr
=
new
DirectorySearcher(de,
"
(CN=
"
+
textBox1.Text
+
"
)
"
);
//
要括起来
ResultPropertyCollection pp
=
sr.FindOne().Properties;
foreach
(
string
ppp
in
pp.PropertyNames)
{
listBox1.Items.Add(ppp);
for
(
int
i
=
0
; i
<
pp[ppp].Count; i
++
)
{
listBox1.Items.Add(
"
---------------->
"
+
pp[ppp][i].ToString());
}
}
}
查看全文
相关阅读:
丑数——剑指offer面试题34
把整数排成最小的数——剑指offer面试题33
从1到n整数中1出现的次数——剑指offer面试题32
各种排序方法及其比较
scrapy安装
水仙花数
分数化小数(decimal)
子序列的和
倒三角
韩信点兵
原文地址:https://www.cnblogs.com/ahuo/p/676853.html
最新文章
sql server 中的简单查询案例
sql server 如何使用sql语句创建表
利用集合和文件的系列,反系列化模拟实现数据的存储功能
利用Io流实现格式化文件夹
利用ArrayList实现简单的管理系统
大话设计模式---单例模式
大话设计模式---迭代器模式
大话设计模式---组合模式
大话设计模式---备忘录模式
大话设计模式---适配器模式
热门文章
大话设计模式---状态模式
大话设计模式---抽象工厂模式
大话设计模式---观察者模式
大话设计模式---建造者模式
大话设计模式---外观模式
算法笔试题
c与c++笔试题
操作系统与计算机笔试题
数据结构笔试题(单选)
一些常用的函数
Copyright © 2011-2022 走看看