asp.net获得客户端域账号_绿色软件之家

绿色软件之家:您身边最放心的安全下载站! 最新更新|软件分类|软件专题|手机版|系统之家|纯净系统

您当前所在位置:首页网络编程.Net编程 → asp.net获得客户端域账号

asp.net获得客户端域账号

时间:2015/6/28来源:绿色软件之家作者:网管联盟我要评论(0)

  To get the windows user name through programatically. Compulsary we need to set the web server.

  Open the Internet Infomation Services(iis), Select your ASP.NET Virtual Directory, right click, go to the Properties, In Properties window go to Directory Security Tab, Here You Find the "Edit" button in Anonymous access and Authentication Control. Press Edit Button. Now Authentication Methods dialogbox will appear.

  In this dialog box by default it is set(checked) Anonymous Access. uncheck this checkbox and go to botom of this dialog box check the Integrated windows authentication. Here why we are selecting this Default web server is logged by ISUER_MachineName so if it is window authentication web server will take the credentials from windows logged user.

  Getting the User Name :

  using three ways we can get the User Name using C#

  1) System.Security.Principal.WindowsPrincipal p = System.Threading.Thread.CurrentPrincipal as System.Security.Principal.WindowsPrincipal;

  string strName = p.Identity.Name;

  [ OR ]

  2) string strName = HttpContext.Current.User.Identity.Name.ToString();

  [ OR ]

  3) string strName = Request.ServerVariables["AUTH_USER"]; //Finding with name

  string strName = Request.ServerVariables[5]; //Finding with index

  In Above 3 Cases returnin string contains DomainName\WinNTLoggedUserName

  (for Ex: Microsoft\Bill.Gates. Here Microsoft is domain Bill.Gates is Logger User Name )

  Using string operations seperate the DomainName and UserName.

关键词标签:asp.net

相关阅读

文章评论
发表评论

热门文章 手把手教你用好LINQ to SQL手把手教你用好LINQ to SQL在.NET环境下为网站增加IP过滤功能在.NET环境下为网站增加IP过滤功能ASP.NET 如何避免页面重新整理时重复送出ASP.NET 如何避免页面重新整理时重复送出用Asp.net扩展ExtJS用Asp.net扩展ExtJS

相关下载

人气排行 asp.net表单提交方法GET\POST在ASP.NET中如何判断用户IE浏览器的版本Asp.net中messagebox的实现方法Asp.net中的web.config配置在ASP.NET MVC中实现大文件异步上传用Iformattable接口控制.Net中文本格式c#.Net经典面试题目用Asp.net扩展ExtJS