nonoblog

获取客户端windows当前登入账号

1.获取客户端当前用户

首先IIS的权限不能设为匿名访问,设为整合Windows访问。 这样在域中就可得到客户端登入电脑账号,域外则需要输入账号密码,不推荐使用,所以此方法只推荐给小型内部web开发。

 Page.User.Identity.Name

2.通过注册表获取本机当前登入用户
   
private string GetRegistData(string name)
    {
        string registData;
        RegistryKey hkml = Registry.Users;
        RegistryKey software = hkml.OpenSubKey("Software", true);
        RegistryKey microsoft = software.OpenSubKey("Microsoft", true);
        RegistryKey windows = microsoft.OpenSubKey("Windows", true);
        RegistryKey currentversion = windows.OpenSubKey("CurrentVersion", true);
        RegistryKey explorer = currentversion.OpenSubKey("Explorer", true);
        registData = explorer.GetValue(name, "").ToString();
        return registData;
    }

  

传入的name为你要取得值。

 

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-01-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2023-04-07
  • 2021-07-16
猜你喜欢
  • 2021-12-18
  • 2022-02-10
  • 2022-12-23
  • 2022-12-23
  • 2022-01-12
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案