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());
}
}
}
查看全文
相关阅读:
完美解决ListView中事件ItemCreated中使用ClientID导致插入数据失败
cookie 和session 的区别详解
ref与out之间的区别整理
showModalDialog介绍
meta元素
[转] Spring Boot特性
[转] Spring Boot 揭秘与实战(二) 数据存储篇
Jsch初步
如何通俗的解释交叉熵与相对熵
pip安装时的异常,找不到lib2to3\Grammar.txt
原文地址:https://www.cnblogs.com/ahuo/p/676853.html
最新文章
使用static与const关键字时需要掌握的知识
浅析栈区和堆区内存分配的区别
不用算术运算符实现两个数的加法(按位异或)
git学习笔记
sizeof计算空间大小的总结
数组小结
JVM垃圾回收机制之引用类型
源码分析八(org.springframework.util包之StringUtils类))
源码分析七(java.lang包之IllegalArgumentException类)
源码分析六(org.springframework.util包之Assert类)
热门文章
源码分析二(ArrayList与LinkedList的区别)
Oracle 正则表达式
源码分析一(Iterator、Collection以及List接口)
oracle数据库中sql%notfound的用法
spring核心之AOP学习总结二
设置局域网共享文件不需要用户名密码
vs2012更改默认开发环境
Win7下telnet使用
Sql server连接数据库报错相关
IE每次关闭都提示IE已停止工作
Copyright © 2011-2022 走看看