Re: Impersonation for accessing network resources?
- From: "Willy Denoyette [MVP]" <willy.denoyette@xxxxxxxxxx>
- Date: Thu, 15 Dec 2005 13:28:52 +0100
Beware "domain\\Administrator" or @"domain\administrator" not
"domain\administrator".
Once you have a connected network session it remains valid for the whole
logon session, that is why you should create a session from your domain
logon (through a logon script) or from a batch file that runs when a user
logs on locally instead of impersonating in user applications.
Willy.
"Ben Fidge" <ben.fidge@xxxxxxxxxxxxxxxxxxxxx> wrote in message
news:%23xZuXRWAGHA.532@xxxxxxxxxxxxxxxxxxxxxxx
> 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.
>>
>>
>>
>
>
.
- Follow-Ups:
- Re: Impersonation for accessing network resources?
- From: Ben Fidge
- Re: Impersonation for accessing network resources?
- References:
- Impersonation for accessing network resources?
- From: Ben Fidge
- Re: Impersonation for accessing network resources?
- From: Willy Denoyette [MVP]
- Re: Impersonation for accessing network resources?
- From: Ben Fidge
- Impersonation for accessing network resources?
- Prev by Date: Re: SID (Security ID)
- Next by Date: Re: gmail with System.Net.Mail.SmtpClient -- release version
- Previous by thread: Re: Impersonation for accessing network resources?
- Next by thread: Re: Impersonation for accessing network resources?
- Index(es):
Relevant Pages
|
Loading