我想使用Windows身份驗證獲取用戶名如何在asp.net中使用Windows身份驗證獲取用戶名?
其實我實現了「以不同的用戶登錄」,當點擊這個按鈕時,Windows安全將出現在那裏,我們可以提供憑證。
在那段時間,如果我給一些其他證書,它只是取當前用戶名。 如何從Windows安全獲取給定的憑證用戶名?
在IIS中的主機應用程序,然後匿名身份驗證已禁用,並啓用Windows身份驗證。
的web.config:
<system.web>
<compilation debug="true" targetFramework="4.0" />
<identity impersonate="true"/>
<authorization>
<allow users="*"/>
<deny users="*"/>
</authorization>
</system.web>
<system.webServer>
<directoryBrowse enabled="true" />
<security>
<authentication>
<anonymousAuthentication enabled="false" />
<windowsAuthentication enabled="true" />
</authentication>
</security>
的.cs
在這裏我得到了默認的用戶名始終
string fullName = Request.ServerVariables["LOGON_USER"];
任何想法?在此先感謝
感謝您的迴應文章...如何使用自定義登錄頁面? – user2148679
我的意思是設計新的登錄頁面。您可以嘗試使用Windows身份驗證的活動目錄身份驗證。你在哪個瀏覽器上運行你的頁面? –