简体   繁体   English

如何从代码获取Windows身份验证的用户名和密码

[英]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.

相关问题 如何从Windows操作系统获取当前用户名和密码。 - How get Current Username and password from windows operating System. 如何从IIS中的Windows身份验证获取用户名输入? - How to get username input from Windows Authentication in IIS? 如何获取和更改Windows凭据用户名和密码 - How to Get and Change Windows Credential Username and Password Windows身份验证中来自sql server的授权用户名和密码 - authorization username and password from sql server in windows authentication Windows身份验证-获取Windows用户名 - Windows Authentication - Get windows username 使用Windows用户名/密码的简单WCF身份验证 - Simple WCF Authentication with windows username/password 如何从用户名和密码获取WindowsPrincipal - How to get WindowsPrincipal from username and password 如何防止某人覆盖获取Windows身份验证并使用用户名进行wcf调用的代码? - How to prevent someone from overriding the code that grabs the windows authentication and uses the username to make wcf calls? Windows Universal App从Microsoft帐户身份验证获取用户名 - Windows Universal App Get username from Microsoft Account Authentication 使用Windows身份验证和匿名身份验证获取用户名 - Get username with Windows Authentication and anonymous authentication
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM