1
A
回答
4
取決於您使用的.NET版本。如果您使用的是.NET版本包含System.DirectoryServices.AccountManagement你可以做到以下幾點:
bool valid = false;
using (PrincipalContext context = new PrincipalContext(ContextType.Domain))
{
valid = context.ValidateCredentials(username, password);
}
變化ContextType.Domain到ContextType.Machine本地機器。您還可以嘗試通過查詢Active Directory來模擬用戶,或嘗試使用類似的方式強制登錄本地系統。但我會推薦上述方法。
public bool IsAuthenticated(string server, string username, string password)
{
bool authenticated = false;
try
{
DirectoryEntry entry = new DirectoryEntry(server, username, password);
object nativeObject = entry.NativeObject;
authenticated = true;
}
catch (DirectoryServicesCOMException cex)
{
//not authenticated; reason why is in cex
}
catch (Exception ex)
{
//not authenticated due to some other exception [this is optional]
}
return authenticated;
}
相關問題
- 1. 使用Outlook憑據驗證Windows身份
- 2. Windows身份驗證不接受憑據
- 3. 根據AD驗證憑據
- 4. 獲取用戶憑證Windows驗證
- 5. 驗證用戶憑據10
- 6. 需要驗證CRM憑據
- 7. 身份驗證憑據
- 8. 驗證域用戶憑據
- 9. 驗證FTP憑證
- 10. ASP.NET Intranet網站要求憑據 - Windows身份驗證
- 11. Windows身份驗證憑據,詢問在IE8和IIS7
- 12. Windows身份驗證不會自動獲取用戶憑據
- 13. 如何驗證UWP應用程序中的Windows憑據
- 14. 無法獲取用戶憑據(Windows身份驗證)
- 15. 不同域上的Windows用戶憑據驗證
- 16. Windows身份驗證模式 - 如何使它不要求憑據?
- 17. 基於Windows身份驗證憑據的MVC自定義角色
- 18. laravel jwtAuth驗證憑證
- 19. 驗證IAM用戶憑證
- 20. Jenkins Packer AWS憑證驗證
- 21. 驗證用戶憑證
- 22. 驗證網站的憑證
- 23. 在命令行驗證域憑據
- 24. 我如何驗證SharePoint用戶憑據
- 25. 審計失敗,憑據驗證4776
- 26. 用於驗證憑據的REST方法
- 27. 發送身份驗證憑據與angular2
- 28. 驗證憑據遠程服務器
- 29. 指定WCF身份驗證憑據
- 30. 無法驗證用戶憑據Python + Flask
想法 - 使用您最喜愛的搜索引擎(Google,Bing,...)並鍵入您的文章標題。 –
我編輯了你的標題。請參閱:「[應該在其標題中包含」標籤「](http://meta.stackexchange.com/questions/19190/)」,其中的共識是「不,他們不應該」。 –