使用ASP.NET获得AD帐号 “域用户名”

mac2022-06-30  66

 

 

1.在IIS中将访问方式更改为不允许匿名访问

2.在Web.config中将验证方式更改为               <identity impersonate="true"/>               <authentication mode="Windows" />

3.在源代码中使用   string username= Security.Principal.WindowsIdentity.GetCurrent().Name

 string[] info = username.Split(new char[1] { '\\' }, StringSplitOptions.RemoveEmptyEntries);

 Domain:info[0]

Name: info[1]

转载于:https://www.cnblogs.com/Mr0909/archive/2011/05/25/2056183.html

相关资源:.net 获取当前电脑的域账号
最新回复(0)