Permission denied problem. please help me

Discussion in 'ASP .Net' started by =?Utf-8?B?QmFsYQ==?=, Aug 28, 2005.

  1. 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
     
    =?Utf-8?B?QmFsYQ==?=, Aug 28, 2005
    #1
    1. Advertising

  2. =?Utf-8?B?QmFsYQ==?=

    Brock Allen Guest

    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
     
    Brock Allen, Aug 29, 2005
    #2
    1. Advertising

  3. Hi Brock,

    Thanks for the reply. The user name which i am using is under the same
    DOMAIN.

    Are you mentioning the same domain user or local user for that machine?

    Thanks
    bala

    "Brock Allen" wrote:

    > 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

    >
    >
    >
    >
     
    =?Utf-8?B?QmFsYQ==?=, Aug 29, 2005
    #3
  4. =?Utf-8?B?QmFsYQ==?=

    Brock Allen Guest

    > Thanks for the reply. The user name which i am using is under the same
    > DOMAIN.


    Ok, that shouldn't matter with delegation.

    > Are you mentioning the same domain user or local user for that
    > machine?


    For delegation you'll have to be using kerb. The username doesn't matter,
    the important thing is to configure the server to be trusted for delegation.

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen
     
    Brock Allen, Aug 29, 2005
    #4
  5. Hi Brock,

    Using this below link code i can able to impersonate the user on my domain
    user account. From my locl machine IIS i can able to download the other
    machine file, like below path.
    ("AnotherNetworkMachine\temp\ss.pdf")

    But when i place this code my server, the impersonate is doing succuss, but
    its taking too much time to download and finally it says page cannot be
    displayed error.

    any idea.

    bala

    http://west-wind.com/weblog/posts/1572.aspx

    "Brock Allen" wrote:

    > > Thanks for the reply. The user name which i am using is under the same
    > > DOMAIN.

    >
    > Ok, that shouldn't matter with delegation.
    >
    > > Are you mentioning the same domain user or local user for that
    > > machine?

    >
    > For delegation you'll have to be using kerb. The username doesn't matter,
    > the important thing is to configure the server to be trusted for delegation.
    >
    > -Brock
    > DevelopMentor
    > http://staff.develop.com/ballen
    >
    >
    >
    >
     
    =?Utf-8?B?QmFsYQ==?=, Aug 29, 2005
    #5
  6. Hi Brock,

    If i create a local account on webserver and same username and password for
    network machine to local, In this point can i able to download the file?

    thanks
    bala

    "Brock Allen" wrote:

    > > Thanks for the reply. The user name which i am using is under the same
    > > DOMAIN.

    >
    > Ok, that shouldn't matter with delegation.
    >
    > > Are you mentioning the same domain user or local user for that
    > > machine?

    >
    > For delegation you'll have to be using kerb. The username doesn't matter,
    > the important thing is to configure the server to be trusted for delegation.
    >
    > -Brock
    > DevelopMentor
    > http://staff.develop.com/ballen
    >
    >
    >
    >
     
    =?Utf-8?B?QmFsYQ==?=, Aug 29, 2005
    #6
  7. sorry. when i run the application on same domain its download the file. but
    from outside i am getting error. so that wont work.

    bala

    "Bala" wrote:

    > Hi Brock,
    >
    > Using this below link code i can able to impersonate the user on my domain
    > user account. From my locl machine IIS i can able to download the other
    > machine file, like below path.
    > ("AnotherNetworkMachine\temp\ss.pdf")
    >
    > But when i place this code my server, the impersonate is doing succuss, but
    > its taking too much time to download and finally it says page cannot be
    > displayed error.
    >
    > any idea.
    >
    > bala
    >
    > http://west-wind.com/weblog/posts/1572.aspx
    >
    > "Brock Allen" wrote:
    >
    > > > Thanks for the reply. The user name which i am using is under the same
    > > > DOMAIN.

    > >
    > > Ok, that shouldn't matter with delegation.
    > >
    > > > Are you mentioning the same domain user or local user for that
    > > > machine?

    > >
    > > For delegation you'll have to be using kerb. The username doesn't matter,
    > > the important thing is to configure the server to be trusted for delegation.
    > >
    > > -Brock
    > > DevelopMentor
    > > http://staff.develop.com/ballen
    > >
    > >
    > >
    > >
     
    =?Utf-8?B?QmFsYQ==?=, Aug 29, 2005
    #7
  8. =?Utf-8?B?QmFsYQ==?=

    Paul Clement Guest

    On Mon, 29 Aug 2005 13:45:32 -0700, "Bala" <> wrote:

    ¤ Hi Brock,
    ¤
    ¤ If i create a local account on webserver and same username and password for
    ¤ network machine to local, In this point can i able to download the file?
    ¤

    As Brock was indicating, you need to delegate credentials which requires Kerberos if your web
    application is configured for Integrated Windows Security.

    How to configure an ASP.NET application for a delegation scenario
    http://support.microsoft.com/default.aspx?scid=kb;en-us;810572


    Paul
    ~~~~
    Microsoft MVP (Visual Basic)
     
    Paul Clement, Aug 30, 2005
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. KK
    Replies:
    2
    Views:
    667
    Big Brian
    Oct 14, 2003
  2. Replies:
    0
    Views:
    1,076
  3. Erik Jensen

    Please help with permission denied on IIS6

    Erik Jensen, Feb 19, 2004, in forum: ASP .Net Security
    Replies:
    0
    Views:
    198
    Erik Jensen
    Feb 19, 2004
  4. stevewa
    Replies:
    2
    Views:
    474
    stevewa
    Aug 13, 2008
  5. Clement Ow
    Replies:
    4
    Views:
    544
    Nick Romney
    Jul 6, 2009
Loading...

Share This Page