Reputation: 1156
I have a heavy client side webapp in AngularJS. I'm using a C# controller to do Active Directory authentication, here is this code.
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.
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.
Upvotes: 2
Views: 910
Reputation: 231
I am not sure I understand AngularJS angle. If I had a regular WCF service I would use WindowsIdentity from ServiceSecurityContext.Current.
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
Upvotes: 1