2012-12-18 122 views

回答

1

我已經在幾個月前完成了這項工作,但是手邊沒有這個代碼。也許我可以稍後檢查它,但這大概是如何工作的:

UserPrincipal up = UserPrincipal.Current; 
foreach (GroupPrincipal gp in up.GetGroups()) 
{ 
    // do something with it, like reading out gp.Name 
} 

希望它有幫助。另外,添加System.DirectoryServices程序集

+0

幾乎 - 您應該使用UserPrincipal up = UserPrincipal.Current獲取當前登錄的用戶... –

+0

PrincipleContext不需要嗎? – efkah

+0

不,這裏不需要'PrincipalContext'。 –

相關問題