[英]C# Active Directory authentication
我在AngularJS中擁有大量的客戶端webapp。 我正在使用C#控制器進行Active Directory身份驗證,這是此代碼。
public UserModel Get()
{
UserModel currentUser = new UserModel();
currentUser.name = User.Identity.Name;
// currentUser.auth = contactFromAD(User.Identity.Name);
currentUser.auth = true;
return currentUser;
}
因此,它的作用是檢查您登錄的AD帳戶,然后執行一些邏輯檢查您是否已通過身份驗證才能訪問該站點。
但是,如何使它在本地主機之外工作。 當代碼在服務器上運行時,如何獲取User.Identity.Name
以返回當前使用該應用程序的人員的身份。
我不確定我是否了解AngularJS角度。 如果我有常規的WCF服務,則可以使用ServiceSecurityContext.Current中的WindowsIdentity。
http://msdn.microsoft.com/en-us/library/system.servicemodel.servicesecuritycontext.aspx
ServiceSecurityContext securityContext = ServiceSecurityContext.Current;
if (securityContext == null)
throw new Exception("Failed to retrieve Service Security Context");
WindowsIdentity identity = securityContext.WindowsIdentity;
currentUser.name = identity.Name
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.