Re: Impersonation fails when accessing remote files.
From: simonc (simon.c_at_gordian.co.uk)
Date: 11/08/04
- Next message: Gary Townsend (Spatial Mapping Ltd.): "Encrypt String or different approach"
- Previous message: Paul Clement: "Re: Impersonation fails when accessing remote files."
- In reply to: Paul Clement: "Re: Impersonation fails when accessing remote files."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Mon, 08 Nov 2004 11:35:18 -0500
Paul,
thanks for the prompt reply. I have already tried using the logon user API
and the result is the same - IE the credentials used to logon are the
aspnet ones not the impersonated ones. Here's the code (Impersonate is
just a wrapper class for the MS standard example of using the logon user
API):
'**** CODE ****
Dim impersonation As Impersonate = New Impersonate
'WhoAmI - will be 'aspnet'
Dim userStr As String = impersonation.WhoAmI
impersonation.SetIdentity(user, pass, domain)
impersonation.BeginImpersonation()
'WhoAmI - will be 'user'
userStr = impersonation.WhoAmI
Dim myFileWebResponse As System.Net.FileWebResponse
Try
Dim url As String = _
"file://192.168.0.1\path\test.pdf"
Dim myFileWebRequest As System.Net.FileWebRequest = _
CType(System.Net.WebRequest.Create(url), _
System.Net.FileWebRequest)
'This call will fail with an access denied exception.
'Server logs show that user 'aspnet' tried to connect.
myFileWebResponse = _
CType(myFileWebRequest.GetResponse(), _
System.Net.FileWebResponse)
Catch ex As System.Net.WebException
Catch ex As UriFormatException
End Try
impersonation.EndImpersonation()
'WhoAmI - back to 'aspnet'
userStr = impersonation.WhoAmI
'***** END CODE ******
I guess I'll have to look into delegation...
- Next message: Gary Townsend (Spatial Mapping Ltd.): "Encrypt String or different approach"
- Previous message: Paul Clement: "Re: Impersonation fails when accessing remote files."
- In reply to: Paul Clement: "Re: Impersonation fails when accessing remote files."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]