string domainAndName = User.Identity.Name;

                string[] infoes = domainAndName.Split(new char[1] { '\\' }, StringSplitOptions.RemoveEmptyEntries);
                string userDomainName = "";
                string userName = "";
                if (infoes.Length > 1)
                {
                    userDomainName = infoes[0];
                    userName = infoes[1];
                }

 

方法2:

 

                WindowsPrincipal wp = new WindowsPrincipal(WindowsIdentity.GetCurrent());
                string[] logon = wp.Identity.Name.Split('\\');
                string UserDomain = logon[0];//网域
                string UserName = logon[1].ToString().ToLower();//登陆名

 

相关文章:

  • 2021-12-31
  • 2022-12-23
  • 2021-11-30
  • 2022-12-23
  • 2021-12-12
  • 2022-12-23
  • 2021-05-25
猜你喜欢
  • 2021-06-15
  • 2022-01-13
  • 2021-09-02
  • 2022-12-23
  • 2022-12-23
  • 2022-01-04
相关资源
相似解决方案