Re: Permission denied problem. please help me

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Impersonation only allows access to local resources as the user who's using your site. You want delegation which will allow off-host access as the user who has authenticated in the browser. In essence it means you need to enable this in AD for the machine that's running your webserver. Check out this for more info:

http://pluralsite.com/wiki/default.aspx/Keith.GuideBook/WhatIsDelegation.html

-Brock
DevelopMentor
http://staff.develop.com/ballen



Hi All,

I am trying to download the file from network machine (under same
domain). I am using below link page code to impersonate.

http://www.netomatix.com/ImpersonateUser.aspx

I can able to impersonate the user, when i try to download the file,
its says "unknown user name and password". I given full permission to
domain user. but the same time when i provied the user name and deails
on webconfig file like below, its allowing me to download.

<identity impersonate="true" userName="mydomain\bala"
password="password" />

I dont know where the problem is. Can anyone please give me idea to
resolve this. I am trying to fix this problem past 3 days.

below is the complete code i am using...

i am getting error on response.writefile. This is the error message

Logon failure: unknown user name or bad password. exception Details:
System.IO.IOException: Logon failure: unknown user name or bad
password.

code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim impContext As WindowsImpersonationContext = Nothing
Try
impContext =
NetworkSecurity.ImpersonateUser("mydomain",
"bala", "password", LogonType.LOGON32_LOGON_NETWORK,
LogonProvider.LOGON32_PROVIDER_DEFAULT)
Catch ex As ApplicationException
impContext.Undo()
Response.Write(ex.Message)
End Try
If Not (Nothing Is impContext) Then
Try
Catch ex As Exception
Response.Write(ex.Message)
Finally
impContext.Undo()
If Page.IsPostBack Then
Dim spath As String
spath = "\\laptop02\temp\test.pdf"
'DownloadFile(spath, True)
Dim path1 As String = spath
Dim name As String = Path.GetFileName(path1)
Dim ext As String = Path.GetExtension(path1)
Dim type As String = ""
If Not (ext Is Nothing) Then
Select Case ext.ToLower
Case ".htm", ".html"
type = "text/HTML"
' break
Case ".txt"
type = "text/plain"
' break
Case ".doc", ".rtf"
type = "Application/msword"
' break
Case ".pdf"
type = "Application/pdf"
End Select
End If
'If forceDownload Then
Response.AppendHeader("content-disposition",
"attachment; filename = " & name)
'End If
If Not (type = "") Then
Response.ContentType = type
End If
Response.WriteFile(path1)
Response.End()
End If
End Try
End If
End Sub
thanks
bala



.



Relevant Pages

  • Re: Impersonate User
    ... > Private Function GetUserDetailsas String ... > Dim arrName() as String ... application or a stand-alone application) am I likely to want to impersonate ... hosting the aspx files get a "Enter Network Password" dialog box when they ...
    (microsoft.public.dotnet.security)
  • Re: impersonate user in windows forms
    ... > The following example demonstrates how to impersonate a user and then ... > Public Shared Function LogonUser(lpszUsername As String, ... > 'The Windows NT user token. ... > Dim token1 As Integer ...
    (microsoft.public.dotnet.languages.vb)
  • Open a file on another domain
    ... program needs to open up that file. ... lpszUsername As [String], _ ... Dim tokenHandle As New IntPtr ... ' And temporarily impersonate said user ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Impersonation in ASP.NET
    ... I've done the 'impersonate with code' bit, but I can't figure out the "make ... the page set up for basic authentication" bit. ... > Public Function Impersonate(ByVal UserName As String, ... > Dim tempWindowsIdentity As WindowsIdentity ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Impersonation in ASP.NET
    ... I've done the 'impersonate with code' bit, but I can't figure out the "make ... the page set up for basic authentication" bit. ... > Public Function Impersonate(ByVal UserName As String, ... > Dim tempWindowsIdentity As WindowsIdentity ...
    (microsoft.public.dotnet.framework.aspnet)