[导入]怎样通过我的domain名称,得知我的group [转帖自ASPCool站]
首先你要知道自己用户的AD Path,例如LDAP://Domain.com/CN=user1,CN=Users,DC=domain,DC=com
然后使用System.DirectoryServices.DirectoryEntry就可以取得对应的AD对象了,其中的"memberof"属性就是用户所在的group的列表。
You can have a look with the sample in MSDN with following URL too:
ms-help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfsystemdirectoryservicessearchresultclasstopic.htm
Something like this:
using System.DirectoryServices;
...
string adPath = @"LDAP://Domain.com/CN=user1,CN=Users,DC=domain,DC=com";
DirectoryEntry user = new DirectoryEntry (adPath);
foreach(object group in user.Properties["memberof"])
{
Console.WriteLine(group.ToString());
}
文章来源:http://computer.mblogger.cn/wucountry/posts/22924.aspx
然后使用System.DirectoryServices.DirectoryEntry就可以取得对应的AD对象了,其中的"memberof"属性就是用户所在的group的列表。
You can have a look with the sample in MSDN with following URL too:
ms-help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfsystemdirectoryservicessearchresultclasstopic.htm
Something like this:
using System.DirectoryServices;
...
string adPath = @"LDAP://Domain.com/CN=user1,CN=Users,DC=domain,DC=com";
DirectoryEntry user = new DirectoryEntry (adPath);
foreach(object group in user.Properties["memberof"])
{
Console.WriteLine(group.ToString());
}
文章来源:http://computer.mblogger.cn/wucountry/posts/22924.aspx
================================
/\_/\
(=^o^=) Wu.Country@侠缘
(~)@(~) 一辈子,用心做一件事!
--------------------------------
学而不思则罔,思而不学则怠!
================================
/\_/\
(=^o^=) Wu.Country@侠缘
(~)@(~) 一辈子,用心做一件事!
--------------------------------
学而不思则罔,思而不学则怠!
================================
posted on 2004-12-11 23:31 Wu.Country@侠缘 阅读(207) 评论(0) 编辑 收藏 举报