1

I need to pass WINDOWS AUTHENTICATION details of logged in user to the pdf converter to make it work. 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.

How can I get credentials with the code?

Gab
  • 471
  • 3
  • 10
  • 25
  • 2
    Do you really need to specify your application user credential to an external PDF convertor. Sound scary... Have you tried AuthenticationOptions.UseDefaultCredentials, its default to true but only when you do not specify UserName? – SBirthare Nov 11 '14 at 08:58
  • 1
    Unfortunately, we have a license only for an old version which doesn't have UseDefaultCredentials property. AuthenticationOptions has only two properties for me(Username and password). – Gab Nov 11 '14 at 09:02
  • Yes, it looks scary for me too, but I can't imagine another solution here... – Gab Nov 11 '14 at 09:03
  • You have a license hence the right to ask for feature that are secure enough. Have you contacted their support team and confirm this? If not I suggest you do that, may be worth. – SBirthare Nov 11 '14 at 09:04
  • 1
    The whole point of windows authentication is that the password is never passed to the remote endpoint - just proof that the user knows/knew their password at an appropriate recent point in the past. – Damien_The_Unbeliever Nov 11 '14 at 09:05
  • @Damien_The_Unbeliever, And how in that case AuthenticationOptions.UseDefaultCredentials works? – Gab Nov 11 '14 at 09:07
  • Surely in this case you need to setup a Service Account (that is a windows user that only sys admins / devs know the details to) and use those credentials. Is there any reason why the current users credentials have to be passed? – RemarkLima Nov 11 '14 at 09:24
  • @Gab - basically, you've received a blob of bytes that prove the user knew their password. Depending on which exact security features you're working with (NTLM vs Kerberos and local vs remote) the windows security system may allow you to impersonate the user (without knowing their password) or delegate for the user (again, without knowing their password). But that depends on API support. – Damien_The_Unbeliever Nov 11 '14 at 09:28

2 Answers2

0

Try this:- (You can use 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.

Rahul Singh
  • 21,585
  • 6
  • 41
  • 56
0

You should upgrade to the latest version which uses the credentials of the current Windows to access the web page from IIS. This can be disabled if you want with HtmlToPdfConverter.AuthenticationOptions.UseDefaultCredentials property

EvoPdf
  • 523
  • 3
  • 9