[英]C# Active Directory authentication
I have a heavy client side webapp in AngularJS. 我在AngularJS中拥有大量的客户端webapp。 I'm using a C# controller to do Active Directory authentication, here is this code.
我正在使用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;
}
So what its doing is checking what AD account you are logged into, then performing some logic to check if you are authenticated to access the site. 因此,它的作用是检查您登录的AD帐户,然后执行一些逻辑检查您是否已通过身份验证才能访问该站点。
However how can I get this to work outside of localhost. 但是,如何使它在本地主机之外工作。 When the code is running server, how can I get
User.Identity.Name
to return the identity of the person currently using the app. 当代码在服务器上运行时,如何获取
User.Identity.Name
以返回当前使用该应用程序的人员的身份。
I am not sure I understand AngularJS angle. 我不确定我是否了解AngularJS角度。 If I had a regular WCF service I would use WindowsIdentity from ServiceSecurityContext.Current.
如果我有常规的WCF服务,则可以使用ServiceSecurityContext.Current中的WindowsIdentity。
http://msdn.microsoft.com/en-us/library/system.servicemodel.servicesecuritycontext.aspx 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.