首页
新闻
博问
会员
闪存
班级
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
星宿.net
星星的随笔
博客园
首页
新随笔
联系
订阅
管理
公告
列出域中所有用户的代码
using
System;
using
System.Data;
using
System.Configuration;
using
System.Collections;
using
System.Web;
using
System.Web.Security;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
System.Web.UI.WebControls.WebParts;
using
System.Web.UI.HtmlControls;
using
System.DirectoryServices;
namespace
WebAppLDAP
{
public
partial
class
_Default : System.Web.UI.Page
{
protected
void
Page_Load(
object
sender, EventArgs e)
{
//
ListAllUser();
showUser();
}
protected
void
showUser()
{
DirectoryEntry entry
=
new
DirectoryEntry(
"
LDAP://ABC.COM.CN
"
);
System.DirectoryServices.DirectorySearcher mySearcher
=
new
System.DirectoryServices.DirectorySearcher(entry);
mySearcher.Filter
=
"
(&(objectClass=user)(objectCategory=person))
"
;
mySearcher.PropertiesToLoad.Add(
"
name
"
);
//
用户名
mySearcher.PropertiesToLoad.Add(
"
samaccountname
"
);
//
用户帐号
SearchResultCollection resultCol
=
mySearcher.FindAll();
foreach
(SearchResult result
in
resultCol)
{
ResultPropertyCollection props
=
result.Properties;
foreach
(
string
propName
in
props.PropertyNames)
{
//
Response.Write(props[propName][0] + "<BR>");
if
(propName
==
"
name
"
)
{
Response.Write(props[propName][
0
]
+
"
<BR>
"
);
}
if
(propName
==
"
samaccountname
"
)
{
Response.Write(props[propName][
0
]
+
"
<BR><BR>
"
);
}
}
}
}
}
}
posted on
2007-05-10 16:12
星宿.NET
阅读(
866
) 评论(
1
)
编辑
收藏
举报
弹尽粮绝,会员救园:会员上线,命悬一线
刷新页面
返回顶部
Powered by:
博客园
Copyright © 2023 星宿.NET
Powered by .NET 7.0 on Kubernetes