[英]How to get username and password of windows authentication from code
I need to pass WINDOWS AUTHENTICATION details of logged in user to the pdf converter to make it work. 我需要将登录用户的WINDOWS AUTHENTICATION详细信息传递给pdf转换器,以使其工作。 I've tried this
我已经试过了
PdfConverter.AuthenticationOptions.Username = CredentialCache.DefaultNetworkCredentials.UserName;
PdfConverter.AuthenticationOptions.Password = CredentialCache.DefaultNetworkCredentials.Password;
But this doesn't help. 但这无济于事。 Converter is working locally, but returning 404 errors in the server where windows authentication is enabled.
Converter在本地运行,但是在启用Windows身份验证的服务器中返回404错误。
How can I get credentials with the code? 如何获得代码的凭据?
Try this:- (You can use WindowsIdentity ) 试试这个:-(您可以使用WindowsIdentity )
WindowsIdentity id = HttpContext.Current.Request.LogonUserIdentity;
String UserName = id.Name;
I don't think we can retrieve password since passwords are not stored in Windows. 我认为我们无法检索密码,因为密码未存储在Windows中。
You should upgrade to the latest version which uses the credentials of the current Windows to access the web page from IIS. 您应该升级到最新版本,该版本使用当前Windows的凭据从IIS访问网页。 This can be disabled if you want with HtmlToPdfConverter.AuthenticationOptions.UseDefaultCredentials property
如果要使用HtmlToPdfConverter.AuthenticationOptions.UseDefaultCredentials属性,可以将其禁用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.