1
웹 페이지가있는 두통이 있습니다.사용자가 IIS 7에서 C#으로 로그인 됨
Windows에 로그인 한 활성 사용자 이름을 얻으려는 웹 페이지 index.aspx 만 있고 직원과 관련된 모든 정보가 표시됩니다.
사용자 이름을 가져올 수 없습니다.
username = (String) HttpContext.Current.User.Identity.Name;
if (username == null) {
username=System.Web.HttpContext.Current.Request.LogonUserIdentity.Name;
username = Environment.UserName;
PrincipalContext ctx = new PrincipalContext(ContextType.Domain);
var user = new UserPrincipal(ctx);
username = user.SamAccountName;
}
:
(내가 프롬프트를 표시 autentification창을 사용하는 경우)
여기내 코드입니다 (내가 일하고 7.0 IIS와 IIS의 모든 autentification는 사용할 수 없습니다) 보시다시피, 나는 사용자를 기록 할 수있는 여러 가지 방법이 있지만, 모두가 null로 표시됩니다.