By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,312 Members | 1,850 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,312 IT Pros & Developers. It's quick & easy.

Problems with authentication/impersonation

P: n/a
Hi

Am having a problem with an app I wrote to test patch delivery. I
contact a remote PC, and get it to run a patch which is installed on a
server. It works fine if I use psexec for example and I know it's not
NTFS/share-level security at fault - it's readable to everyone which
is usually enough for scheduler or any other usually-not-network-user
to reach it.

I've checked my credentials in my remote session and it says it's
running as "me", but it appears I've lost my network identity.

check.cmd is just basically "dir \\server\share >> c:\log.log 2>&1",
but when called remotely it results in "Access is denied" in the log.
If I change it to "dir c:\ ...", it works fine though. Remember, I'm
calling that batch file on the remote PC. I'm also a domain admin by
the way, and for good measure I've also added myself to the admins
group on my remote test pc.

Here's the code:

Dim options = New ConnectionOptions
options.EnablePrivileges = True
options.Authentication = AuthenticationLevel.Call
options.Impersonation = ImpersonationLevel.Impersonate

Dim scope = New ManagementScope("\\" + pc + "\root\cimv2", options)
scope.Connect()

Dim processClass = New ManagementClass("Win32_Process")
processClass.Scope = scope

Dim inParams = processClass.GetMethodParameters("Create")

Dim startup = New ManagementClass("WIN32_ProcessStartup")
startup.Scope = scope

inParams("CommandLine") = "cmd /c c:\check.cmd"
inParams("ProcessStartupInformation") = startup
Dim outParams = processClass.InvokeMethod("Create", inParams, Nothing)

Debug.WriteLine("CreateProcess returned :" +
outParams("ReturnValue").ToString())
Any that can help with this will earn my undying gratitude and respect
(and a million pounds!)*

Cheers

AW

* offer of prize money will not be honoured :)
Nov 20 '05 #1
Share this Question
Share on Google+
22 Replies


P: n/a
Per default domain admins have no rights to access WMI on member servers.
You can check and enable this running wmimgmt.msc on the remote server (or
running it on a local machine and connecting to a remote server).
Right click on WMI Control and select properties, in the control properties
dialog click the "security" tab and add the domain admin account to the ACL
list, make sure at least "execute", "read and write" and "remote enable" are
selected.

Willy.

"andrew_webby at hotmail" <an**********@hotmail.com> wrote in message
news:f4************************@posting.google.com ...
Hi

Am having a problem with an app I wrote to test patch delivery. I
contact a remote PC, and get it to run a patch which is installed on a
server. It works fine if I use psexec for example and I know it's not
NTFS/share-level security at fault - it's readable to everyone which
is usually enough for scheduler or any other usually-not-network-user
to reach it.

I've checked my credentials in my remote session and it says it's
running as "me", but it appears I've lost my network identity.

check.cmd is just basically "dir \\server\share >> c:\log.log 2>&1",
but when called remotely it results in "Access is denied" in the log.
If I change it to "dir c:\ ...", it works fine though. Remember, I'm
calling that batch file on the remote PC. I'm also a domain admin by
the way, and for good measure I've also added myself to the admins
group on my remote test pc.

Here's the code:

Dim options = New ConnectionOptions
options.EnablePrivileges = True
options.Authentication = AuthenticationLevel.Call
options.Impersonation = ImpersonationLevel.Impersonate

Dim scope = New ManagementScope("\\" + pc + "\root\cimv2", options)
scope.Connect()

Dim processClass = New ManagementClass("Win32_Process")
processClass.Scope = scope

Dim inParams = processClass.GetMethodParameters("Create")

Dim startup = New ManagementClass("WIN32_ProcessStartup")
startup.Scope = scope

inParams("CommandLine") = "cmd /c c:\check.cmd"
inParams("ProcessStartupInformation") = startup
Dim outParams = processClass.InvokeMethod("Create", inParams, Nothing)

Debug.WriteLine("CreateProcess returned :" +
outParams("ReturnValue").ToString())
Any that can help with this will earn my undying gratitude and respect
(and a million pounds!)*

Cheers

AW

* offer of prize money will not be honoured :)

Nov 20 '05 #2

P: n/a
ms
Hi Willy

Thanks for the suggestions. However, I tried adding Domain Admins in where
you suggest and it didn't help.

Although I am a domain admin (and therefore by default in the local
'Administrators' group on the member PCs - which already have the
permissions you suggest), I am actually trying this in two different
configurations. One from WinXP -> WinXP and one from Win2k3 -> WinXP.

My problem doesn't appear to be the accessing/creation/whatever of WMI - I
can create the remote process no problem. It's just when I want that remote
process to access the network that my troubles begin.

Any other suggestions as I'm running a little short on hair here... ;)

AW

"Willy Denoyette [MVP]" <wi*************@pandora.be> wrote in message
news:OV**************@TK2MSFTNGP11.phx.gbl...
Per default domain admins have no rights to access WMI on member servers.
You can check and enable this running wmimgmt.msc on the remote server (or
running it on a local machine and connecting to a remote server).
Right click on WMI Control and select properties, in the control properties dialog click the "security" tab and add the domain admin account to the ACL list, make sure at least "execute", "read and write" and "remote enable" are selected.

Willy.

Nov 20 '05 #3

P: n/a

"ms" <andrew_webby@hotmail> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi Willy

Thanks for the suggestions. However, I tried adding Domain Admins in where
you suggest and it didn't help.


Hi Andrew,

Sorry, should have read your post more carefully.
The problem you have is the famous multiple hop issue when using NTLM
authentication.
The remote process is impersonating "me" (the token obtained is a
impersonation token - no user/password was obtained by this process), that
means you don't have network credentials, and anonymous (I'm not sure this
is the case on W2K3) will be used to access the shared network resource.
One thing you could try is to force Kerberos authentication, and set
ImpersonationLevel.Delegate (so you will have to set
ConnectionOption.Authority = "Kerberos:<principalname>).
But, even that is not guaranteed to work, as WMI is free to reject Kerberos
and fall back to NTLM authentication.

I suggest you enabled auditing on the remote share, that way you can check
which account is used to access the share?

Willy.
Nov 20 '05 #4

P: n/a
Hmm.

I see it's trying to connect to my share as remotepcname$ which is of course
the machine's 'user' account in the domain. So for fun and larks, I gave
access to the PC inquestion at the share/ntfs level but it still won't work.

This would even do for anonymous readonly access to the world if I could get
that to work. I'll see what I can find on the Kerberos side, but so far this
doesn't sound very encouraging....

http://msdn.microsoft.com/library/de...delegation.asp

That seems to be suggesting I would need to mark every client computer in my
domain as Trusted For Delegation - which I'm not really willing to do.

There must be an easier way, surely? A colleague here suggested mapping a
network drive remotely with a username/password and maybe that would clear
up the ID issue - what do you reckon?

Thanks for the top suggestions so far :)

AW

"Willy Denoyette [MVP]" <wi*************@pandora.be> wrote in message
news:u3****************@TK2MSFTNGP10.phx.gbl...

"ms" <andrew_webby@hotmail> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi Willy

Thanks for the suggestions. However, I tried adding Domain Admins in where you suggest and it didn't help.

Hi Andrew,

Sorry, should have read your post more carefully.
The problem you have is the famous multiple hop issue when using NTLM
authentication.
The remote process is impersonating "me" (the token obtained is a
impersonation token - no user/password was obtained by this process), that
means you don't have network credentials, and anonymous (I'm not sure this
is the case on W2K3) will be used to access the shared network resource.
One thing you could try is to force Kerberos authentication, and set
ImpersonationLevel.Delegate (so you will have to set
ConnectionOption.Authority = "Kerberos:<principalname>).
But, even that is not guaranteed to work, as WMI is free to reject

Kerberos and fall back to NTLM authentication.

I suggest you enabled auditing on the remote share, that way you can check
which account is used to access the share?

Willy.

Nov 20 '05 #5

P: n/a
Andrew,
I've done some tests myself, and as far I see this can't work, simply
because WMI (actually wmiprvse.exe) launches the command shell (cmd) in the
security context of the impersonated domain account, but it's logon type is
3 (NETWORK), that means its token is obtained by a network logon, so it runs
without network privileges!
Note that Kerberos was used to authenticate the client, but the ticket
obtained by WMI is dropped on the floor when he starts another process.

PS. I'm not clear as why you see machine$ is used to access the share, are
you sure it's not the Logon session event written when wmiprvse.exe is
spawned by svchost.exe?

Willy.

"andrew_webby at hotmail" <andrew_webby@hotmail> wrote in message
news:Or**************@tk2msftngp13.phx.gbl...
Hmm.

I see it's trying to connect to my share as remotepcname$ which is of
course
the machine's 'user' account in the domain. So for fun and larks, I gave
access to the PC inquestion at the share/ntfs level but it still won't
work.

This would even do for anonymous readonly access to the world if I could
get
that to work. I'll see what I can find on the Kerberos side, but so far
this
doesn't sound very encouraging....

http://msdn.microsoft.com/library/de...delegation.asp

That seems to be suggesting I would need to mark every client computer in
my
domain as Trusted For Delegation - which I'm not really willing to do.

There must be an easier way, surely? A colleague here suggested mapping a
network drive remotely with a username/password and maybe that would clear
up the ID issue - what do you reckon?

Thanks for the top suggestions so far :)

AW

"Willy Denoyette [MVP]" <wi*************@pandora.be> wrote in message
news:u3****************@TK2MSFTNGP10.phx.gbl...

"ms" <andrew_webby@hotmail> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
> Hi Willy
>
> Thanks for the suggestions. However, I tried adding Domain Admins in where > you suggest and it didn't help.
>


Hi Andrew,

Sorry, should have read your post more carefully.
The problem you have is the famous multiple hop issue when using NTLM
authentication.
The remote process is impersonating "me" (the token obtained is a
impersonation token - no user/password was obtained by this process),
that
means you don't have network credentials, and anonymous (I'm not sure
this
is the case on W2K3) will be used to access the shared network resource.
One thing you could try is to force Kerberos authentication, and set
ImpersonationLevel.Delegate (so you will have to set
ConnectionOption.Authority = "Kerberos:<principalname>).
But, even that is not guaranteed to work, as WMI is free to reject

Kerberos
and fall back to NTLM authentication.

I suggest you enabled auditing on the remote share, that way you can
check
which account is used to access the share?

Willy.


Nov 20 '05 #6

P: n/a
Andrew,
I've done some tests myself, and as far I see this can't work, simply
because WMI (actually wmiprvse.exe) launches the command shell (cmd) in the
security context of the impersonated domain account, but it's logon type is
3 (NETWORK), that means its token is obtained by a network logon, so it runs
without network privileges!
Note that Kerberos was used to authenticate the client, but the ticket
obtained by WMI is dropped on the floor when he starts another process.

PS. I'm not clear as why you see machine$ is used to access the share, are
you sure it's not the Logon session event written when wmiprvse.exe is
spawned by svchost.exe?

Willy.

"andrew_webby at hotmail" <andrew_webby@hotmail> wrote in message
news:Or**************@tk2msftngp13.phx.gbl...
Hmm.

I see it's trying to connect to my share as remotepcname$ which is of
course
the machine's 'user' account in the domain. So for fun and larks, I gave
access to the PC inquestion at the share/ntfs level but it still won't
work.

This would even do for anonymous readonly access to the world if I could
get
that to work. I'll see what I can find on the Kerberos side, but so far
this
doesn't sound very encouraging....

http://msdn.microsoft.com/library/de...delegation.asp

That seems to be suggesting I would need to mark every client computer in
my
domain as Trusted For Delegation - which I'm not really willing to do.

There must be an easier way, surely? A colleague here suggested mapping a
network drive remotely with a username/password and maybe that would clear
up the ID issue - what do you reckon?

Thanks for the top suggestions so far :)

AW

"Willy Denoyette [MVP]" <wi*************@pandora.be> wrote in message
news:u3****************@TK2MSFTNGP10.phx.gbl...

"ms" <andrew_webby@hotmail> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
> Hi Willy
>
> Thanks for the suggestions. However, I tried adding Domain Admins in where > you suggest and it didn't help.
>


Hi Andrew,

Sorry, should have read your post more carefully.
The problem you have is the famous multiple hop issue when using NTLM
authentication.
The remote process is impersonating "me" (the token obtained is a
impersonation token - no user/password was obtained by this process),
that
means you don't have network credentials, and anonymous (I'm not sure
this
is the case on W2K3) will be used to access the shared network resource.
One thing you could try is to force Kerberos authentication, and set
ImpersonationLevel.Delegate (so you will have to set
ConnectionOption.Authority = "Kerberos:<principalname>).
But, even that is not guaranteed to work, as WMI is free to reject

Kerberos
and fall back to NTLM authentication.

I suggest you enabled auditing on the remote share, that way you can
check
which account is used to access the share?

Willy.


Nov 20 '05 #7

P: n/a
I reviewed most of the thread. Did you enable the computer account that is
the WMI Server in Active Directory to be enabled for delegation? Also is
the file share mentioned a part of this Active Directory or one if it's
member servers?

The other steps are also required, enabling kerberos authority and
specifying the delegation on the Impersonation Level.

--
[MS] Scott McNairy
WMI Test Engineer
This posting is provided "As Is" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

"Willy Denoyette [MVP]" <wi*************@pandora.be> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Andrew,
I've done some tests myself, and as far I see this can't work, simply
because WMI (actually wmiprvse.exe) launches the command shell (cmd) in the security context of the impersonated domain account, but it's logon type is 3 (NETWORK), that means its token is obtained by a network logon, so it runs without network privileges!
Note that Kerberos was used to authenticate the client, but the ticket
obtained by WMI is dropped on the floor when he starts another process.

PS. I'm not clear as why you see machine$ is used to access the share, are
you sure it's not the Logon session event written when wmiprvse.exe is
spawned by svchost.exe?

Willy.

"andrew_webby at hotmail" <andrew_webby@hotmail> wrote in message
news:Or**************@tk2msftngp13.phx.gbl...
Hmm.

I see it's trying to connect to my share as remotepcname$ which is of
course
the machine's 'user' account in the domain. So for fun and larks, I gave
access to the PC inquestion at the share/ntfs level but it still won't
work.

This would even do for anonymous readonly access to the world if I could
get
that to work. I'll see what I can find on the Kerberos side, but so far
this
doesn't sound very encouraging....

http://msdn.microsoft.com/library/de...delegation.asp
That seems to be suggesting I would need to mark every client computer in my
domain as Trusted For Delegation - which I'm not really willing to do.

There must be an easier way, surely? A colleague here suggested mapping a network drive remotely with a username/password and maybe that would clear up the ID issue - what do you reckon?

Thanks for the top suggestions so far :)

AW

"Willy Denoyette [MVP]" <wi*************@pandora.be> wrote in message
news:u3****************@TK2MSFTNGP10.phx.gbl...

"ms" <andrew_webby@hotmail> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
> Hi Willy
>
> Thanks for the suggestions. However, I tried adding Domain Admins in

where
> you suggest and it didn't help.
>

Hi Andrew,

Sorry, should have read your post more carefully.
The problem you have is the famous multiple hop issue when using NTLM
authentication.
The remote process is impersonating "me" (the token obtained is a
impersonation token - no user/password was obtained by this process),
that
means you don't have network credentials, and anonymous (I'm not sure
this
is the case on W2K3) will be used to access the shared network resource. One thing you could try is to force Kerberos authentication, and set
ImpersonationLevel.Delegate (so you will have to set
ConnectionOption.Authority = "Kerberos:<principalname>).
But, even that is not guaranteed to work, as WMI is free to reject

Kerberos
and fall back to NTLM authentication.

I suggest you enabled auditing on the remote share, that way you can
check
which account is used to access the share?

Willy.



Nov 20 '05 #8

P: n/a
I reviewed most of the thread. Did you enable the computer account that is
the WMI Server in Active Directory to be enabled for delegation? Also is
the file share mentioned a part of this Active Directory or one if it's
member servers?

The other steps are also required, enabling kerberos authority and
specifying the delegation on the Impersonation Level.

--
[MS] Scott McNairy
WMI Test Engineer
This posting is provided "As Is" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

"Willy Denoyette [MVP]" <wi*************@pandora.be> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Andrew,
I've done some tests myself, and as far I see this can't work, simply
because WMI (actually wmiprvse.exe) launches the command shell (cmd) in the security context of the impersonated domain account, but it's logon type is 3 (NETWORK), that means its token is obtained by a network logon, so it runs without network privileges!
Note that Kerberos was used to authenticate the client, but the ticket
obtained by WMI is dropped on the floor when he starts another process.

PS. I'm not clear as why you see machine$ is used to access the share, are
you sure it's not the Logon session event written when wmiprvse.exe is
spawned by svchost.exe?

Willy.

"andrew_webby at hotmail" <andrew_webby@hotmail> wrote in message
news:Or**************@tk2msftngp13.phx.gbl...
Hmm.

I see it's trying to connect to my share as remotepcname$ which is of
course
the machine's 'user' account in the domain. So for fun and larks, I gave
access to the PC inquestion at the share/ntfs level but it still won't
work.

This would even do for anonymous readonly access to the world if I could
get
that to work. I'll see what I can find on the Kerberos side, but so far
this
doesn't sound very encouraging....

http://msdn.microsoft.com/library/de...delegation.asp
That seems to be suggesting I would need to mark every client computer in my
domain as Trusted For Delegation - which I'm not really willing to do.

There must be an easier way, surely? A colleague here suggested mapping a network drive remotely with a username/password and maybe that would clear up the ID issue - what do you reckon?

Thanks for the top suggestions so far :)

AW

"Willy Denoyette [MVP]" <wi*************@pandora.be> wrote in message
news:u3****************@TK2MSFTNGP10.phx.gbl...

"ms" <andrew_webby@hotmail> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
> Hi Willy
>
> Thanks for the suggestions. However, I tried adding Domain Admins in

where
> you suggest and it didn't help.
>

Hi Andrew,

Sorry, should have read your post more carefully.
The problem you have is the famous multiple hop issue when using NTLM
authentication.
The remote process is impersonating "me" (the token obtained is a
impersonation token - no user/password was obtained by this process),
that
means you don't have network credentials, and anonymous (I'm not sure
this
is the case on W2K3) will be used to access the shared network resource. One thing you could try is to force Kerberos authentication, and set
ImpersonationLevel.Delegate (so you will have to set
ConnectionOption.Authority = "Kerberos:<principalname>).
But, even that is not guaranteed to work, as WMI is free to reject

Kerberos
and fall back to NTLM authentication.

I suggest you enabled auditing on the remote share, that way you can
check
which account is used to access the share?

Willy.



Nov 20 '05 #9

P: n/a
Morning guys :)

Thanks for all the great assistance with this. I didn't try making the
computer account (that's my 'control' computer yeah, and not the ones that
are being told to install the patch?) enabled for delegation so I'll give
that a go just now.

Scott, yeah all the pieces in the jigsaw are part of the same domain. I have
two domain's I'm trying in, one is Native and the other is Mixed. XP -> XP
and 2k3 -> XP are the platforms I'm trying on at the moment.

Anyway, after a nights sleep, I came up with a workaround, but it's one of
those "well, only if I must deals". Kind of hoped I was past kludges like
this, but hey-ho.

I just drop a batch file on the client's computer, and then spawn my process
with a password passed to it (in clear text over the LAN, but as it's a
lowly non-logonable account that shouldn't matter too much. The patch$ share
is world-readable.).

The batch file looks like this:
@echo off
net use \\server\patch$ /user:DOMAIN\lowly_user %1
dir \\server\patch$>> c:\log.log 2>&1
net use \\server\patch$ /d
echo done>> c:\log.log 2>&1

And that's the job done. I then start my process as "install <password>".

A bit fakey and I cringe at the thought of passing passwords around, but I
should be able to lock it down a bit.

I'll persist on the kerberos option for a while as I can't get my process to
start with the current code and see what comes up.

Out of interest, here's my problem with that:

Dim options = New ConnectionOptions
options.EnablePrivileges = True
options.Authentication = AuthenticationLevel.Call ' (tried them all)
options.Impersonation = ImpersonationLevel.Delegate ' (tried them all, too
:))
options.authority = "Kerberos:DOMAIN\andreww"
options.username = "DOMAIN\andreww" (tried with/without this line)
options.password = txtPassword.Text
Dim scope = New ManagementScope("\\" + pc + "\root\cimv2", options)
scope.Connect() **** FAILS HERE with TARGET INVOCATION EXCEPTION

Dim processClass = New ManagementClass("Win32_Process")
processClass.Scope = scope
Dim inParams = processClass.GetMethodParameters("Create")
Dim startup = New ManagementClass("WIN32_ProcessStartup")
startup.Scope = scopeinParams("CommandLine") = "c:\check.cmd " &
txtPassword.Text
inParams("ProcessStartupInformation") = startup
Dim outParams = processClass.InvokeMethod("Create", inParams, Nothing)
Debug.WriteLine("CreateProcess returned :" +
outParams("ReturnValue").ToString())

The above bit works fine with ImpersonationLevel.Impersonate - it just gets
screwed up when changed to delegate so I'm not sure what's going on there.
Back to the books I think :)

Thanks again for the help guys.

Cheers

AW

"[MS] Scott McNairy" <sc****@online.microsoft.com> wrote in message
news:40********@news.microsoft.com...
I reviewed most of the thread. Did you enable the computer account that is the WMI Server in Active Directory to be enabled for delegation? Also is
the file share mentioned a part of this Active Directory or one if it's
member servers?

The other steps are also required, enabling kerberos authority and
specifying the delegation on the Impersonation Level.

--
[MS] Scott McNairy
WMI Test Engineer
This posting is provided "As Is" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

"Willy Denoyette [MVP]" <wi*************@pandora.be> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Andrew,
I've done some tests myself, and as far I see this can't work, simply
because WMI (actually wmiprvse.exe) launches the command shell (cmd) in

the
security context of the impersonated domain account, but it's logon type

is
3 (NETWORK), that means its token is obtained by a network logon, so it

runs
without network privileges!
Note that Kerberos was used to authenticate the client, but the ticket
obtained by WMI is dropped on the floor when he starts another process.

PS. I'm not clear as why you see machine$ is used to access the share, are you sure it's not the Logon session event written when wmiprvse.exe is
spawned by svchost.exe?

Willy.

Nov 20 '05 #10

P: n/a
Morning guys :)

Thanks for all the great assistance with this. I didn't try making the
computer account (that's my 'control' computer yeah, and not the ones that
are being told to install the patch?) enabled for delegation so I'll give
that a go just now.

Scott, yeah all the pieces in the jigsaw are part of the same domain. I have
two domain's I'm trying in, one is Native and the other is Mixed. XP -> XP
and 2k3 -> XP are the platforms I'm trying on at the moment.

Anyway, after a nights sleep, I came up with a workaround, but it's one of
those "well, only if I must deals". Kind of hoped I was past kludges like
this, but hey-ho.

I just drop a batch file on the client's computer, and then spawn my process
with a password passed to it (in clear text over the LAN, but as it's a
lowly non-logonable account that shouldn't matter too much. The patch$ share
is world-readable.).

The batch file looks like this:
@echo off
net use \\server\patch$ /user:DOMAIN\lowly_user %1
dir \\server\patch$>> c:\log.log 2>&1
net use \\server\patch$ /d
echo done>> c:\log.log 2>&1

And that's the job done. I then start my process as "install <password>".

A bit fakey and I cringe at the thought of passing passwords around, but I
should be able to lock it down a bit.

I'll persist on the kerberos option for a while as I can't get my process to
start with the current code and see what comes up.

Out of interest, here's my problem with that:

Dim options = New ConnectionOptions
options.EnablePrivileges = True
options.Authentication = AuthenticationLevel.Call ' (tried them all)
options.Impersonation = ImpersonationLevel.Delegate ' (tried them all, too
:))
options.authority = "Kerberos:DOMAIN\andreww"
options.username = "DOMAIN\andreww" (tried with/without this line)
options.password = txtPassword.Text
Dim scope = New ManagementScope("\\" + pc + "\root\cimv2", options)
scope.Connect() **** FAILS HERE with TARGET INVOCATION EXCEPTION

Dim processClass = New ManagementClass("Win32_Process")
processClass.Scope = scope
Dim inParams = processClass.GetMethodParameters("Create")
Dim startup = New ManagementClass("WIN32_ProcessStartup")
startup.Scope = scopeinParams("CommandLine") = "c:\check.cmd " &
txtPassword.Text
inParams("ProcessStartupInformation") = startup
Dim outParams = processClass.InvokeMethod("Create", inParams, Nothing)
Debug.WriteLine("CreateProcess returned :" +
outParams("ReturnValue").ToString())

The above bit works fine with ImpersonationLevel.Impersonate - it just gets
screwed up when changed to delegate so I'm not sure what's going on there.
Back to the books I think :)

Thanks again for the help guys.

Cheers

AW

"[MS] Scott McNairy" <sc****@online.microsoft.com> wrote in message
news:40********@news.microsoft.com...
I reviewed most of the thread. Did you enable the computer account that is the WMI Server in Active Directory to be enabled for delegation? Also is
the file share mentioned a part of this Active Directory or one if it's
member servers?

The other steps are also required, enabling kerberos authority and
specifying the delegation on the Impersonation Level.

--
[MS] Scott McNairy
WMI Test Engineer
This posting is provided "As Is" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

"Willy Denoyette [MVP]" <wi*************@pandora.be> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Andrew,
I've done some tests myself, and as far I see this can't work, simply
because WMI (actually wmiprvse.exe) launches the command shell (cmd) in

the
security context of the impersonated domain account, but it's logon type

is
3 (NETWORK), that means its token is obtained by a network logon, so it

runs
without network privileges!
Note that Kerberos was used to authenticate the client, but the ticket
obtained by WMI is dropped on the floor when he starts another process.

PS. I'm not clear as why you see machine$ is used to access the share, are you sure it's not the Logon session event written when wmiprvse.exe is
spawned by svchost.exe?

Willy.

Nov 20 '05 #11

P: n/a
Hi Scott,
Thanks, got it working (as expected) using delegation of credentials.
My problem was that the Workstation service was excluded for delegation on
the server running WMI.
Note that you need to set ImpersonationLevel.Delegate but I didn't need to
set the Kerberos authority, isn't that enabled per default in a "pure"
Kerberos realm?

Willy.
"[MS] Scott McNairy" <sc****@online.microsoft.com> wrote in message
news:40********@news.microsoft.com...
I reviewed most of the thread. Did you enable the computer account that is
the WMI Server in Active Directory to be enabled for delegation? Also is
the file share mentioned a part of this Active Directory or one if it's
member servers?

The other steps are also required, enabling kerberos authority and
specifying the delegation on the Impersonation Level.

--
[MS] Scott McNairy
WMI Test Engineer

Nov 20 '05 #12

P: n/a
Hi Scott,
Thanks, got it working (as expected) using delegation of credentials.
My problem was that the Workstation service was excluded for delegation on
the server running WMI.
Note that you need to set ImpersonationLevel.Delegate but I didn't need to
set the Kerberos authority, isn't that enabled per default in a "pure"
Kerberos realm?

Willy.
"[MS] Scott McNairy" <sc****@online.microsoft.com> wrote in message
news:40********@news.microsoft.com...
I reviewed most of the thread. Did you enable the computer account that is
the WMI Server in Active Directory to be enabled for delegation? Also is
the file share mentioned a part of this Active Directory or one if it's
member servers?

The other steps are also required, enabling kerberos authority and
specifying the delegation on the Impersonation Level.

--
[MS] Scott McNairy
WMI Test Engineer

Nov 20 '05 #13

P: n/a
Andrew,

See my my reply to Scott's posting, so I guess you have it working by now.

Willy.

"andrew_webby at hotmail" <andrew_webby@hotmail> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
Morning guys :)

Thanks for all the great assistance with this. I didn't try making the
computer account (that's my 'control' computer yeah, and not the ones that
are being told to install the patch?) enabled for delegation so I'll give
that a go just now.

Scott, yeah all the pieces in the jigsaw are part of the same domain. I
have
two domain's I'm trying in, one is Native and the other is Mixed. XP -> XP
and 2k3 -> XP are the platforms I'm trying on at the moment.

Anyway, after a nights sleep, I came up with a workaround, but it's one of
those "well, only if I must deals". Kind of hoped I was past kludges like
this, but hey-ho.

I just drop a batch file on the client's computer, and then spawn my
process
with a password passed to it (in clear text over the LAN, but as it's a
lowly non-logonable account that shouldn't matter too much. The patch$
share
is world-readable.).

The batch file looks like this:
@echo off
net use \\server\patch$ /user:DOMAIN\lowly_user %1
dir \\server\patch$>> c:\log.log 2>&1
net use \\server\patch$ /d
echo done>> c:\log.log 2>&1

And that's the job done. I then start my process as "install <password>".

A bit fakey and I cringe at the thought of passing passwords around, but I
should be able to lock it down a bit.

I'll persist on the kerberos option for a while as I can't get my process
to
start with the current code and see what comes up.

Out of interest, here's my problem with that:

Dim options = New ConnectionOptions
options.EnablePrivileges = True
options.Authentication = AuthenticationLevel.Call ' (tried them all)
options.Impersonation = ImpersonationLevel.Delegate ' (tried them all,
too
:))
options.authority = "Kerberos:DOMAIN\andreww"
options.username = "DOMAIN\andreww" (tried with/without this line)
options.password = txtPassword.Text
Dim scope = New ManagementScope("\\" + pc + "\root\cimv2", options)
scope.Connect() **** FAILS HERE with TARGET INVOCATION EXCEPTION

Dim processClass = New ManagementClass("Win32_Process")
processClass.Scope = scope
Dim inParams = processClass.GetMethodParameters("Create")
Dim startup = New ManagementClass("WIN32_ProcessStartup")
startup.Scope = scopeinParams("CommandLine") = "c:\check.cmd " &
txtPassword.Text
inParams("ProcessStartupInformation") = startup
Dim outParams = processClass.InvokeMethod("Create", inParams, Nothing)
Debug.WriteLine("CreateProcess returned :" +
outParams("ReturnValue").ToString())

The above bit works fine with ImpersonationLevel.Impersonate - it just
gets
screwed up when changed to delegate so I'm not sure what's going on there.
Back to the books I think :)

Thanks again for the help guys.

Cheers

AW

"[MS] Scott McNairy" <sc****@online.microsoft.com> wrote in message
news:40********@news.microsoft.com...
I reviewed most of the thread. Did you enable the computer account that

is
the WMI Server in Active Directory to be enabled for delegation? Also is
the file share mentioned a part of this Active Directory or one if it's
member servers?

The other steps are also required, enabling kerberos authority and
specifying the delegation on the Impersonation Level.

--
[MS] Scott McNairy
WMI Test Engineer
This posting is provided "As Is" with no warranties, and confers no

rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

"Willy Denoyette [MVP]" <wi*************@pandora.be> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
> Andrew,
> I've done some tests myself, and as far I see this can't work, simply
> because WMI (actually wmiprvse.exe) launches the command shell (cmd) in

the
> security context of the impersonated domain account, but it's logon
> type

is
> 3 (NETWORK), that means its token is obtained by a network logon, so it

runs
> without network privileges!
> Note that Kerberos was used to authenticate the client, but the ticket
> obtained by WMI is dropped on the floor when he starts another process.
>
> PS. I'm not clear as why you see machine$ is used to access the share, are > you sure it's not the Logon session event written when wmiprvse.exe is
> spawned by svchost.exe?
>
> Willy.


Nov 20 '05 #14

P: n/a
Andrew,

See my my reply to Scott's posting, so I guess you have it working by now.

Willy.

"andrew_webby at hotmail" <andrew_webby@hotmail> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
Morning guys :)

Thanks for all the great assistance with this. I didn't try making the
computer account (that's my 'control' computer yeah, and not the ones that
are being told to install the patch?) enabled for delegation so I'll give
that a go just now.

Scott, yeah all the pieces in the jigsaw are part of the same domain. I
have
two domain's I'm trying in, one is Native and the other is Mixed. XP -> XP
and 2k3 -> XP are the platforms I'm trying on at the moment.

Anyway, after a nights sleep, I came up with a workaround, but it's one of
those "well, only if I must deals". Kind of hoped I was past kludges like
this, but hey-ho.

I just drop a batch file on the client's computer, and then spawn my
process
with a password passed to it (in clear text over the LAN, but as it's a
lowly non-logonable account that shouldn't matter too much. The patch$
share
is world-readable.).

The batch file looks like this:
@echo off
net use \\server\patch$ /user:DOMAIN\lowly_user %1
dir \\server\patch$>> c:\log.log 2>&1
net use \\server\patch$ /d
echo done>> c:\log.log 2>&1

And that's the job done. I then start my process as "install <password>".

A bit fakey and I cringe at the thought of passing passwords around, but I
should be able to lock it down a bit.

I'll persist on the kerberos option for a while as I can't get my process
to
start with the current code and see what comes up.

Out of interest, here's my problem with that:

Dim options = New ConnectionOptions
options.EnablePrivileges = True
options.Authentication = AuthenticationLevel.Call ' (tried them all)
options.Impersonation = ImpersonationLevel.Delegate ' (tried them all,
too
:))
options.authority = "Kerberos:DOMAIN\andreww"
options.username = "DOMAIN\andreww" (tried with/without this line)
options.password = txtPassword.Text
Dim scope = New ManagementScope("\\" + pc + "\root\cimv2", options)
scope.Connect() **** FAILS HERE with TARGET INVOCATION EXCEPTION

Dim processClass = New ManagementClass("Win32_Process")
processClass.Scope = scope
Dim inParams = processClass.GetMethodParameters("Create")
Dim startup = New ManagementClass("WIN32_ProcessStartup")
startup.Scope = scopeinParams("CommandLine") = "c:\check.cmd " &
txtPassword.Text
inParams("ProcessStartupInformation") = startup
Dim outParams = processClass.InvokeMethod("Create", inParams, Nothing)
Debug.WriteLine("CreateProcess returned :" +
outParams("ReturnValue").ToString())

The above bit works fine with ImpersonationLevel.Impersonate - it just
gets
screwed up when changed to delegate so I'm not sure what's going on there.
Back to the books I think :)

Thanks again for the help guys.

Cheers

AW

"[MS] Scott McNairy" <sc****@online.microsoft.com> wrote in message
news:40********@news.microsoft.com...
I reviewed most of the thread. Did you enable the computer account that

is
the WMI Server in Active Directory to be enabled for delegation? Also is
the file share mentioned a part of this Active Directory or one if it's
member servers?

The other steps are also required, enabling kerberos authority and
specifying the delegation on the Impersonation Level.

--
[MS] Scott McNairy
WMI Test Engineer
This posting is provided "As Is" with no warranties, and confers no

rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

"Willy Denoyette [MVP]" <wi*************@pandora.be> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
> Andrew,
> I've done some tests myself, and as far I see this can't work, simply
> because WMI (actually wmiprvse.exe) launches the command shell (cmd) in

the
> security context of the impersonated domain account, but it's logon
> type

is
> 3 (NETWORK), that means its token is obtained by a network logon, so it

runs
> without network privileges!
> Note that Kerberos was used to authenticate the client, but the ticket
> obtained by WMI is dropped on the floor when he starts another process.
>
> PS. I'm not clear as why you see machine$ is used to access the share, are > you sure it's not the Logon session event written when wmiprvse.exe is
> spawned by svchost.exe?
>
> Willy.


Nov 20 '05 #15

P: n/a
Not sure - I think it needs to be specified somewhere otherwise it will
default to NTLM.

--
[MS] Scott McNairy
WMI Test Engineer
This posting is provided "As Is" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

"Willy Denoyette [MVP]" <wi*************@pandora.be> wrote in message
news:uB**************@tk2msftngp13.phx.gbl...
Hi Scott,
Thanks, got it working (as expected) using delegation of credentials.
My problem was that the Workstation service was excluded for delegation on
the server running WMI.
Note that you need to set ImpersonationLevel.Delegate but I didn't need to
set the Kerberos authority, isn't that enabled per default in a "pure"
Kerberos realm?

Willy.
"[MS] Scott McNairy" <sc****@online.microsoft.com> wrote in message
news:40********@news.microsoft.com...
I reviewed most of the thread. Did you enable the computer account that is the WMI Server in Active Directory to be enabled for delegation? Also is the file share mentioned a part of this Active Directory or one if it's
member servers?

The other steps are also required, enabling kerberos authority and
specifying the delegation on the Impersonation Level.

--
[MS] Scott McNairy
WMI Test Engineer


Nov 20 '05 #16

P: n/a
Not sure - I think it needs to be specified somewhere otherwise it will
default to NTLM.

--
[MS] Scott McNairy
WMI Test Engineer
This posting is provided "As Is" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

"Willy Denoyette [MVP]" <wi*************@pandora.be> wrote in message
news:uB**************@tk2msftngp13.phx.gbl...
Hi Scott,
Thanks, got it working (as expected) using delegation of credentials.
My problem was that the Workstation service was excluded for delegation on
the server running WMI.
Note that you need to set ImpersonationLevel.Delegate but I didn't need to
set the Kerberos authority, isn't that enabled per default in a "pure"
Kerberos realm?

Willy.
"[MS] Scott McNairy" <sc****@online.microsoft.com> wrote in message
news:40********@news.microsoft.com...
I reviewed most of the thread. Did you enable the computer account that is the WMI Server in Active Directory to be enabled for delegation? Also is the file share mentioned a part of this Active Directory or one if it's
member servers?

The other steps are also required, enabling kerberos authority and
specifying the delegation on the Impersonation Level.

--
[MS] Scott McNairy
WMI Test Engineer


Nov 20 '05 #17

P: n/a


"[MS] Scott McNairy" <sc****@online.microsoft.com> wrote in message
news:40********@news.microsoft.com...
Not sure - I think it needs to be specified somewhere otherwise it will
default to NTLM.

--


Scott,

Well I didn't set the Kerberos authority, what I'm seeing is that the
Negotiate SSP selects Kerberos and succeeds when delegation stuff is
correctly set-up.
That makes me think that setting the authority (to Kerberos or NTLM) is to
force the SSP to use one and only one of the protocols.
I will further investigate this and come back later.

Willy.
Nov 20 '05 #18

P: n/a


"[MS] Scott McNairy" <sc****@online.microsoft.com> wrote in message
news:40********@news.microsoft.com...
Not sure - I think it needs to be specified somewhere otherwise it will
default to NTLM.

--


Scott,

Well I didn't set the Kerberos authority, what I'm seeing is that the
Negotiate SSP selects Kerberos and succeeds when delegation stuff is
correctly set-up.
That makes me think that setting the authority (to Kerberos or NTLM) is to
force the SSP to use one and only one of the protocols.
I will further investigate this and come back later.

Willy.
Nov 20 '05 #19

P: n/a
Turns out that if the domain controller is configured or setup to run in
compatibility mode that can host Pre-Win2k Windows versions like NT4 and
Win9x, then the default is NTLM. If it is not, the default is kerberos
authority.

--
[MS] Scott McNairy
WMI Test Engineer
This posting is provided "As Is" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

"Willy Denoyette [MVP]" <wi*************@pandora.be> wrote in message
news:OX**************@TK2MSFTNGP12.phx.gbl...


"[MS] Scott McNairy" <sc****@online.microsoft.com> wrote in message
news:40********@news.microsoft.com...
Not sure - I think it needs to be specified somewhere otherwise it will
default to NTLM.

--


Scott,

Well I didn't set the Kerberos authority, what I'm seeing is that the
Negotiate SSP selects Kerberos and succeeds when delegation stuff is
correctly set-up.
That makes me think that setting the authority (to Kerberos or NTLM) is to
force the SSP to use one and only one of the protocols.
I will further investigate this and come back later.

Willy.

Nov 20 '05 #20

P: n/a
Turns out that if the domain controller is configured or setup to run in
compatibility mode that can host Pre-Win2k Windows versions like NT4 and
Win9x, then the default is NTLM. If it is not, the default is kerberos
authority.

--
[MS] Scott McNairy
WMI Test Engineer
This posting is provided "As Is" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

"Willy Denoyette [MVP]" <wi*************@pandora.be> wrote in message
news:OX**************@TK2MSFTNGP12.phx.gbl...


"[MS] Scott McNairy" <sc****@online.microsoft.com> wrote in message
news:40********@news.microsoft.com...
Not sure - I think it needs to be specified somewhere otherwise it will
default to NTLM.

--


Scott,

Well I didn't set the Kerberos authority, what I'm seeing is that the
Negotiate SSP selects Kerberos and succeeds when delegation stuff is
correctly set-up.
That makes me think that setting the authority (to Kerberos or NTLM) is to
force the SSP to use one and only one of the protocols.
I will further investigate this and come back later.

Willy.

Nov 20 '05 #21

P: n/a

"[MS] Scott McNairy" <sc****@online.microsoft.com> wrote in message
news:40********@news.microsoft.com...
Turns out that if the domain controller is configured or setup to run in
compatibility mode that can host Pre-Win2k Windows versions like NT4 and
Win9x, then the default is NTLM. If it is not, the default is kerberos
authority.

Scott,

Well, that's what I meant with .... enabled per default in a "pure" Kerberos
realm?
So if you need to be sure Kerberos is used you better set it explicitely.
Willy.
Nov 20 '05 #22

P: n/a

"[MS] Scott McNairy" <sc****@online.microsoft.com> wrote in message
news:40********@news.microsoft.com...
Turns out that if the domain controller is configured or setup to run in
compatibility mode that can host Pre-Win2k Windows versions like NT4 and
Win9x, then the default is NTLM. If it is not, the default is kerberos
authority.

Scott,

Well, that's what I meant with .... enabled per default in a "pure" Kerberos
realm?
So if you need to be sure Kerberos is used you better set it explicitely.
Willy.
Nov 20 '05 #23

This discussion thread is closed

Replies have been disabled for this discussion.