windows-identity

MVC3 Windows Authentication override User.Identity

只谈情不闲聊 提交于 2019-11-29 00:50:35
问题 I am building a intranet application using MVC3 with a MSSQL backend. I have authentication and roles (through a custom roles provider) working properly. What I am trying to do now is overriding User.Identity to allow for items like User.Identity.FirstName. But I cannot find any code that will show me how do this in WindowsIdentity I have tried writing a custom provider: public class CPrincipal : WindowsPrincipal { UserDAL userDAL = new UserDAL(); public CPrincipal(WindowsIdentity identity) :

How to create WindowsIdentity/WindowsPrincipal from username in DOMAIN\\user format

こ雲淡風輕ζ 提交于 2019-11-27 22:52:34
The WindowsIdentity(string) constructor requires the username to be in username@domain.com format. But in my case I get the usernames from a DB in the old DOMAIN\user format (and then have to check their Windows role membership). What is the best way of creating WindowsPrincipal from the old style (sAMAccountName) username? It does seem that there is no way of converting the username format without involving a query to Active Directory. Since that is the case there is no need to create WindowsPrincipal for checking the group membership since that would probably need yet another connection to

How do I get the currently loggedin Windows account from an ASP.NET page?

别等时光非礼了梦想. 提交于 2019-11-27 08:19:17
I have an ASP.NET 3.5 application that uses ASP.NET forms authentication. I want to be able to get the Windows user name currently logged into the computer (NOT logged into the ASP.NET application, but into Windows) when data is edited in a page. If I use Context.User.Identity.Name.Tostring() , I get the user name logged into the ASP.NET application, but I need the Windows account name. System.Security.Principal.WindowsIdentity.GetCurrent().Name.Tostring() Also, it only works when I run the website from Visual Studio, but after deploying to IIS it returns NT AUTHORITY\SYSTEM . You have to set

How to create WindowsIdentity/WindowsPrincipal from username in DOMAIN\user format

让人想犯罪 __ 提交于 2019-11-26 21:11:53
问题 The WindowsIdentity(string) constructor requires the username to be in username@domain.com format. But in my case I get the usernames from a DB in the old DOMAIN\user format (and then have to check their Windows role membership). What is the best way of creating WindowsPrincipal from the old style (sAMAccountName) username? 回答1: It does seem that there is no way of converting the username format without involving a query to Active Directory. Since that is the case there is no need to create

How do I get the currently loggedin Windows account from an ASP.NET page?

烂漫一生 提交于 2019-11-26 14:07:04
问题 I have an ASP.NET 3.5 application that uses ASP.NET forms authentication. I want to be able to get the Windows user name currently logged into the computer (NOT logged into the ASP.NET application, but into Windows) when data is edited in a page. If I use Context.User.Identity.Name.Tostring() , I get the user name logged into the ASP.NET application, but I need the Windows account name. System.Security.Principal.WindowsIdentity.GetCurrent().Name.Tostring() Also, it only works when I run the