[英]Website deployed on IIS not getting the domain NT login
我使用IIS在服務器上部署了ASP.net網站。 問題在於,它拒絕訪問同一域中的網站的任何人。 我要做的是,一旦用戶嘗試訪問服務器上的網站,我就會讀取該用戶的NT登錄名,並將其與我的Db中存在的NT登錄名相匹配,並且如果該人的NT登錄名存在於數據庫中,則將其授予訪問權限。 現在,在調試之后,我先檢查了用於存儲User NT登錄名的變量,然后再與數據庫進行了檢查,無論誰訪問該網站,傳遞的登錄名都是用於部署該網站的服務器的登錄名。
Webcofig:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
<identity impersonate="true" />
</system.web>
<system.webServer>
<defaultDocument>
<files>
<add value="User_login_Portal.aspx" />
</files>
</defaultDocument>
</system.webServer>
<connectionStrings>
<add name="myConnectionString"
connectionString="Server=Server;Database=Backend_UM;User
ID=sa;Password=Password;Trusted_Connection=False;"
providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
ASPCode:
string x = Environment.UserName;
string y = Page.User.Identity.Name;
string strName = HttpContext.Current.User.Identity.Name.ToString();
WindowsIdentity currentIdentity = WindowsIdentity.GetCurrent();
string NTlogin = currentIdentity.Name.ToString();
string[] login_name = NTlogin.Split('\\');
login = loginid.Text = login_name[1];
認證:
Windows身份驗證:已啟用
ASP.net模擬:已啟用
論壇身份驗證:已禁用
匿名身份驗證:已禁用
身份:ApplicationPoolIdentity
Asp代碼中的登錄變量假定是嘗試訪問它的人員的NT登錄用戶名,但是無論誰嘗試訪問網站,登錄變量都是部署門戶網站的服務器的用戶名。
問題已解決。 在部署網站時,我需要選中Windows身份驗證復選框。 由於我沒有這樣做,因此網站只會采用部署它的服務器的用戶名。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.