Wu.Country@侠缘

勤学似春起之苗,不见其增,日有所长; 辍学如磨刀之石,不见其损,日所有亏!

导航

[导入]怎样通过我的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

posted on 2004-12-11 23:31  Wu.Country@侠缘  阅读(207)  评论(0编辑  收藏  举报