Re: Impersonation for accessing network resources?
- From: "Willy Denoyette [MVP]" <willy.denoyette@xxxxxxxxxx>
- Date: Fri, 16 Dec 2005 18:14:15 +0100
You should not use LOGON32_LOGON_NETWORK to obtain an access token to access
remote server resources when impersonating, this type of logon token has no
network access.
LOGON32_LOGON_NEW_CREDENTIALS (w2k and up) uses the supplied credentials to
access the remote server, while using your current logon token to access
local resources.
Willy.
"Ben Fidge" <BenFidge@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:E6C985C7-7D7C-475A-8DA8-DEB8B4F46059@xxxxxxxxxxxxxxxx
> Found it!!
>
> First of all, I was assuming that LogonUser returned 0 (zero) on success,
> wrongly. Secondly, I changed my code to use LOGON32_LOGON_NEW_CREDENTIALS
> instead of LOGON32_LOGON_NETWORK, and it works a treat.
>
> Thanks for your help Willy.
>
> Ben
>
> "Ben Fidge" wrote:
>
>> Hi Willy,
>>
>> Does LogonUser login the specified user into the local system only, or
>> can
>> it be used to specify credentials when accessing a network resource. I've
>> tried everything you've suggested and it's occured to me that I'm trying
>> to
>> provide credentials for the administrator account of the SERVER where my
>> files are located. I'm owrried I might actually be trying to logon to my
>> local machine using credentials it knows nothing about.
>>
>> Ben
>>
>> "Willy Denoyette [MVP]" wrote:
>>
>> >
>> > "Ben Fidge" <ben.fidge@xxxxxxxxxxxxxxxxxxxxx> wrote in message
>> > news:ebI7rJYAGHA.3780@xxxxxxxxxxxxxxxxxxxxxxx
>> > > Hi Willy,
>> > >
>> > > The domain, account and password are all entered via a Form and not
>> > > hard-coded. I've tried passing all three to LogonUser as seperate
>> > > parameters, to no avail. I've also tried leaving domain param empty
>> > > (not
>> > > null though) and concatenating doman and account together and passing
>> > > them
>> > > in the Account param.
>> > >
>> > > Really starting to frustrate me now.
>> > >
>> > > Ben
>> > >
>> >
>> > I understand your frustration, but you need to make sure that
>> > - the user account string you pass to LogonUser() has the correct
>> > syntax,
>> > that is, it should contain the accountname "accountname" or the
>> > "account@domainname" in UPN format
>> > - the domain name must refer to your account domain if the user name is
>> > NOT
>> > in UPN format, else it must be null or . for local user accounts or the
>> > remote machine name for non local/non domain accounts.
>> > So in your case the call could look like :
>> >
>> > LogonUser("Administrator", "YourDomainName", "YourAdminsPwd",...);
>> >
>> > Willy.
>> >
>> >
>> >
>> >
.
- 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
- Re: Impersonation for accessing network resources?
- From: Willy Denoyette [MVP]
- Re: Impersonation for accessing network resources?
- From: Ben Fidge
- Re: Impersonation for accessing network resources?
- From: Willy Denoyette [MVP]
- Impersonation for accessing network resources?
- Prev by Date: Re: inherite windows forms user control
- Next by Date: Web App Without IIS
- Previous by thread: Re: Impersonation for accessing network resources?
- Next by thread: C# Excel file can't be opened normally
- Index(es):
Relevant Pages
|