[英]Accessing Active Directory with Asp.Net Identity framework without ADFS
[英]Does ASP.NET Identity work with an on-premise Active Directory without ADFS?
我可以使用ActiveDirectoryMembership-Provider找到示例,但是找不到有關如何使用ASP.NET Identity在Intranet上下文中使用Active Directory進行身份驗證的信息。
身份框架應該代替成員資格和角色提供者,但是它似乎不允許沒有ADFS的身份驗證到本地活動目錄。
是否可以將身份與非ADFS Active Directory一起使用? 如果沒有,建議改用ActiveDirectoryMembership-Provider嗎?
我目前正在使用LdapConnection(System.DirectoryServices.Protocols)將用戶綁定到AD,並將用戶名存儲為會話變量。 然后,我可以檢查用戶是否已登錄到每個頁面的PreInit事件中。 但是我正在尋找一種使用應用程序范圍內身份驗證的方法,以及一種檢查AD中用戶角色的方法。
您需要使用ADVAPI32.dll從Intranet Active Directory驗證用戶。
[DllImport("ADVAPI32.dll", EntryPoint = "LogonUserW", SetLastError = true, CharSet = CharSet.Auto)]
public static extern bool LogonUser(string lpszUsername, string lpszDomain, string lpszPassword, int dwLogonType, int dwLogonProvider, ref IntPtr phToken);
LogonUser(userName, domainName, password, 3, 1, ref token);
此代碼可以幫助您使用Active Directory驗證用戶。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.