2011-08-31 229 views
2

要在Active Directory中檢查用戶是否存在,哪個更適合使用.Net庫?驗證Active Directory用戶

System.Web.Security.ActiveDirectoryMembershipProvider 

System.DirectoryServices 

我使用的System.DirectoryServices,我覺得它是用一個確切。我確實看到here中提供了類似的功能。

請指教。

回答

2

由於您使用的是.NET 4.0,因此您應該查看System.DirectoryServices.AccountManagement(S.DS.AM)命名空間。在這裏閱讀全部內容:

基本上,你可以定義域範圍內,並可以輕鬆地查找用戶和/或組AD:

// set up domain context 
PrincipalContext ctx = new PrincipalContext(ContextType.Domain); 

// find a user 
UserPrincipal user = UserPrincipal.FindByIdentity(ctx, "SomeUserName"); 

if(user != null) 
{ 
    // do something here....  
} 

的新的S.DS.AM可以很容易地與AD中的用戶和羣組玩耍!

+0

是的,它是正確的。我的問題是我可以使用System.Web.Security.ActiveDirectoryMembershipProvider用於類似的目的嗎? – Roshe

+1

@Nilaa:這是ASP.NET成員資格提供程序 - 需要單獨且正確地配置,不確定是否可以在沒有安裝所有設置的情況下使用它。我不會使用它 - 除非你已經使用ASP.NET會員資料.... –

相關問題