Re: Impersonation for accessing network resources?



Basically I've been using [domain]\Administrator and [password] the same as
I enter when I try to access the mapped drive from explorer. However it
works in explorer but not my app. However, if I first connect using
Explorer, I then don't need to use LogonUser. Strange!

Ben


"Willy Denoyette [MVP]" <willy.denoyette@xxxxxxxxxx> wrote in message
news:Obz6ugLAGHA.3864@xxxxxxxxxxxxxxxxxxxxxxx
>
> "Ben Fidge" <BenFidge@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:B024D767-93F7-49E9-94D4-E0CC31871F31@xxxxxxxxxxxxxxxx
>> Hi
>>
>> I have a small WinForms app that needs to copy files from a shared drive
>> on
>> a network. If I connect to the mapped drive using Explorer, a password
>> dialog
>> pops-up and I have to provide credentials with permission to access this
>> resource on the machine where it's hosted. This is once for each desktop
>> logon session (ie after every reboot). If I do this, my app can access
>> the
>> network resource fine, but otherwise fails with permission errors.
>>
>> As my app runs when Windows starts, I don't want to first connect to the
>> mapped drive each and every time.
>>
>> I've found some C# code that allows me to impersonate a
>> domain/account/password context, but it won't work in the scenario I
>> want. I
>> know the code works because it allows me to impersonate local accounts,
>> just
>> not access the network resource. When run, the following error occurs:
>>
>> "Error No: 1326 - Error: Logon failure: unknown user name or bad
>> password."
>>
>> However, I know the domain/account/password are all correct.
>>
>> The code is based on Win32 API's LogonUser. Am I barking up the wrong
>> tree?
>>
>> Thanks
>>
>> Ben
>>
>
> If you call LogonUser you should specify the credentials of a valid user
> that has appropriate privileges to access the remote server.
>
>
> Willy.
>
>
>


.



Relevant Pages

  • Re: Impersonation for accessing network resources?
    ... my app can access the ... > network resource fine, but otherwise fails with permission errors. ... If you call LogonUser you should specify the credentials of a valid user ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Explorer crashes when I open a folder or view drives in my com
    ... I went to my computer and opened one of the drives. ... App: E:\WINDOWS\Explorer.EXE ... Mike on the south coast of the UK ... Explorer needs to re start message is displayed ...
    (microsoft.public.windowsxp.perform_maintain)
  • Re: Songbird...
    ... So basically you dont need any application other than explorer? ... a column that list all the albums a column that lists all the ... and like iTunes can do. ... Yup, a media playing app, that's it's primary purpose. ...
    (uk.comp.sys.mac)
  • Re: Emulating Zenworks Application Explorer with SMS?
    ... It's really student access I'm most concerned about. ... we cannot add every app required to the image that is in use ... a user can traverse through the Application Explorer ... standard program installs in 'Program Files' - e.g. ...
    (microsoft.public.sms.setup)
  • Files dropped on Explorer doesnt arrive - delay rendering
    ... Since these zipped files can be large and contain more files ... Everything works as expected, only that explorer doesn't ... Tried dropping it to every app I saw on my PC that accept files (VS, ... One more thing that maybe should be mentioned: While unzipping I ...
    (microsoft.public.vc.mfc)

Loading