Google グループは Usenet の新規の投稿と購読のサポートを終了しました。過去のコンテンツは引き続き閲覧できます。
Dismiss

Wired error of get-credential for non-privilege user

閲覧: 34 回
最初の未読メッセージにスキップ

TonyDeSweet

未読、
2006/01/27 11:36:412006/01/27
To:
Not sure if it is right place, but I discovered this while using monad.

System: Windows XP Home, .NET Framework SDK 2.0, Monad beta3

If login as a member of Administrators group, MSH.exe runs perfectly.
I am writing "su.msh" script (go to http://mshforfun.blogspot.com/
for detail)

There is a non-privilege user "testac" who belong to Users and
Everyone group. When login as "testac", msh.exe launched OK. If
you login as a member of Administrators group and try to launch msh.exe
(within a msh window of course) using RUNAS.exe (runas /profile
/User:testac msh.exe), msh.exe launched OK.

Problem really come out when you using get-credential cmdlet and pass
Username and Password to Process.Start() method.

$SuAccount = get-credential
$StartInfo = new-object System.Diagnostics.ProcessStartInfo
$StartInfo.FileName = "msh.exe"
$StartInfo.Arguments = "-nologo -noprofile"
$StartInfo.UserName = $SuAccount.UserName
$StartInfo.Password = $SuAccount.Password
$StartInfo.LoadUserProfile = $true
$StartInfo.UseShellExecute = $false
$StartInfo.WorkingDirectory = (get-location).Path
[System.Diagnostics.Process]::Start($StartInfo)

First time you run script:
Cmdlet get-credential at command pipeline position 1
Supply values for the following parameters:
Credential
Exception calling "Start" with "1" argument(s): "Logon failure: unknown
user name or bad password"
At D:\msh\su.msh:11 char:36
+ [System.Diagnostics.Process]::Start( <<<< $StartInfo)

Second time you run script:
No error, works like runas

Third time you run script:
Cmdlet get-credential at command pipeline position 1
Supply values for the following parameters:
Credential
Exception calling "Start" with "1" argument(s): "Logon failure: unknown
user name or bad password"
At D:\msh\su.msh:11 char:36
+ [System.Diagnostics.Process]::Start( <<<< $StartInfo)

Fourth time you run script:
No error, works like runas

Fifth time you run script:
Cmdlet get-credential at command pipeline position 1
Supply values for the following parameters:
Credential
Exception calling "Start" with "1" argument(s): "Logon failure: unknown
user name or bad password"
At D:\msh\su.msh:11 char:36
+ [System.Diagnostics.Process]::Start( <<<< $StartInfo)

So you see patterns here? I don't have detailed trace information,
but I am pretty sure there is something wrong with get-credential
cmdlet (or maybe it is Process.Start() method). Or it is simply a bug?


Tony
http://mshforfun.blogspot.com/

/\/\o\/\/ [MVP]

未読、
2006/01/27 13:00:432006/01/27
To:
Did you fill the credentials ?

Otherwise you get in a loop between the Shell's(bug filed)

See, also :

http://mow001.blogspot.com/2005/10/do-msh-cmd-msh-loop-runas-in-msh.html
http://mow001.blogspot.com/2005/10/runas-with-loading-profile-script-in.html

think this is happening here also.
try changing a dir and then do a LS to test this.

gr /\/\o\/\/

/\/\o\/\/ [MVP]

未読、
2006/01/27 13:42:562006/01/27
To:
No, I think this is a new one, try setting the ConsolePrompting to True :

new-property HKLM:\SOFTWARE\Microsoft\MSH\1\ShellIds -property
ConsolePrompting -value "True" -force

and try you script again, If I use the GUI I have the same effect.
as you have.

MSH>$cred = get-credential

Cmdlet get-credential at command pipeline position 1
Supply values for the following parameters:
Credential

User: test
Password for user test: *******

MSH>$PSI = new-object System.Diagnostics.ProcessStartInfo
MSH>$psi.LoadUserProfile = $true
MSH>$psi.filename = "MSH.exe"
MSH>$psi.UseShellExecute = $false
MSH>
MSH>$psi.Username = $cred.userName
MSH>$psi.Password = $cred.Password
MSH>
MSH>[System.Diagnostics.Process]::start($PSI)

Handles NPM(K) PM(K) WS(K) VS(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
12 1 324 1032 14 0,03 5916 msh


MSH>[System.Diagnostics.Process]::start($PSI)

Handles NPM(K) PM(K) WS(K) VS(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
5 1 132 428 5 0,02 5972 msh


MSH>[System.Diagnostics.Process]::start($PSI)

Handles NPM(K) PM(K) WS(K) VS(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
5 1 132 428 5 0,02 628 msh


MSH>[System.Diagnostics.Process]::start($PSI)

Handles NPM(K) PM(K) WS(K) VS(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
5 1 132 428 5 0,03 3420 msh

So, I think this is a bug in the CredUI.

gr /\/\o\/\/

TonyDeSweet

未読、
2006/01/27 14:25:542006/01/27
To:
Well, good to know!

I will try the ConsolePrompting mode of get-credential.

lee.h...@online.microsoft.com

未読、
2006/01/27 15:50:552006/01/27
To:
Thanks, Tony.

The difference in behaviour (between CredUI and the console prompting) is that CredUI returns us a username with "\" prepended. As in "\testac". This is another valid form of the same username.

When we pass that to the Process.Start method, it has intermittent difficulty dealing with that form of a username. You'll see the same effect if you prepend your username with a "\" from the Console prompting.

Interestingly enough, you won't see the problem happen if you keep the first successful console window open.

--
Lee Holmes [MSFT]
Microsoft Command Shell Development
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.

TonyDeSweet

未読、
2006/01/27 16:39:082006/01/27
To:
Yes, I do see a "\testac" from the very begining. But I did not realize
this is the problem though. Thanks.

Tony
http://mshforfun.blogspot.com/

新着メール 0 件