当客户机IE浏览器打开网址URL ,在页面显示AD域名\账号。
案例代码
通过域名/账号查询使用者工号,依据工号判断是否有权限使用该页面程式,如下:
if (!IsPostBack)
{
if ((Page.User.Identity.AuthenticationType.ToString() == "Negotiate") || (Page.User.Identity.AuthenticationType.ToString() == "NTLM")) //Negotiate,NTLM
{
if (Page.User.Identity.Name.IndexOf('\\') < 1)
{
Response.Redirect(System.Configuration.ConfigurationManager.AppSettings["urlMappingErrorPage"].ToString(), true);
return;
}
v_domain = Page.User.Identity.Name.Split('\\')[0].ToString();
v_domainaccount = Page.User.Identity.Name.Split('\\')[1].ToString();
v_empID = Coeno.Account.Users.GetUserEmpID(v_domain.ToUpper(), v_domainaccount.ToUpper());
}
else
{
v_empID = Page.User.Identity.Name;
}
if (v_empID == "")
{
Response.Redirect(System.Configuration.ConfigurationManager.AppSettings["urlMappingErrorPage"].ToString(), true);
return;
}
txtCurrentEmpID.Text = v_empID;
if (Coeno.Assistant.Assistants.CheckIsAssistByAssist(v_empID) != 1)
{ //检查是否有助理权限,如果没有则跳转到拒绝页面
Response.Redirect(System.Configuration.ConfigurationManager.AppSettings["urlPermissionDenied"].ToString());
return;
}
else
{
//如果有助理权限,则进行其他代码处理
}
}上述代码使用,需配置事项,如下:
IE安全设置,不可匿名,如下:
web.config 验证mos配置,如下
<!--
<authentication> 區段可以用來設定 ASP.NET
使用的安全性驗證模式,以識別連入的
使用者。
-->
<authentication mode="Windows"/>当客户机IE浏览器打开网址URL ,在页面显示AD域名\账号,如下:
3150

被折叠的 条评论
为什么被折叠?



