Click here to Skip to main content
15,887,304 members
Home / Discussions / C#
   

C#

 
QuestionCan't run SC remotely to config service Pin
SledgeHammer012-May-13 13:43
SledgeHammer012-May-13 13:43 
AnswerRe: Can't run SC remotely to config service Pin
Dave Kreskowiak2-May-13 15:42
mveDave Kreskowiak2-May-13 15:42 
GeneralRe: Can't run SC remotely to config service Pin
SledgeHammer012-May-13 17:39
SledgeHammer012-May-13 17:39 
GeneralRe: Can't run SC remotely to config service Pin
Dave Kreskowiak3-May-13 1:21
mveDave Kreskowiak3-May-13 1:21 
GeneralRe: Can't run SC remotely to config service Pin
SledgeHammer013-May-13 4:08
SledgeHammer013-May-13 4:08 
GeneralRe: Can't run SC remotely to config service Pin
SledgeHammer013-May-13 7:21
SledgeHammer013-May-13 7:21 
GeneralRe: Can't run SC remotely to config service Pin
Dave Kreskowiak3-May-13 7:52
mveDave Kreskowiak3-May-13 7:52 
GeneralRe: Can't run SC remotely to config service Pin
SledgeHammer013-May-13 8:04
SledgeHammer013-May-13 8:04 
Dave Kreskowiak wrote:
Nope. You're running a command line app and the command prompt is telling you
who it's running as. If the user isn't what you expected it to be, well, that's
a problem in your code, not the test. This is telling you who the SC command is
running as. If that account doesn't have the appropriate permissions to the
target machine to start and stop services, it's going to fail.


Ok Mr. Smarty Pants Smile | :) (j/k)... explain this one... I have just proved again that the impersonation code I am using is working:

using (new Impersonator(_strDomain, _strUsername, _strPassword))
{
System.Diagnostics.Debug.WriteLine(System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString());

System.Diagnostics.Process.Start("CMD", "/K WHOAMI");
}

I have just conducted two tests there... your CMD /K WHOAMI (which returns the wrong non-impersonated logged on user) and WindowsIdentity.GetCurrent() (which CORRECTLY returns the impersonated user!)

I am running on Windows 7 as an admin on my box (but not the remote box), UAC is disabled. So that block of code *is* running as the impersonated user, but Process.Start() seems to be running as non impersonated currently logged on user.
GeneralRe: Can't run SC remotely to config service Pin
Dave Kreskowiak3-May-13 8:26
mveDave Kreskowiak3-May-13 8:26 
GeneralRe: Can't run SC remotely to config service Pin
SledgeHammer013-May-13 9:40
SledgeHammer013-May-13 9:40 
GeneralRe: Can't run SC remotely to config service Pin
SledgeHammer013-May-13 11:10
SledgeHammer013-May-13 11:10 
AnswerRe: Can't run SC remotely to config service Pin
Richard MacCutchan2-May-13 21:37
mveRichard MacCutchan2-May-13 21:37 
GeneralRe: Can't run SC remotely to config service Pin
SledgeHammer013-May-13 4:02
SledgeHammer013-May-13 4:02 
GeneralRe: Can't run SC remotely to config service Pin
Richard MacCutchan3-May-13 4:22
mveRichard MacCutchan3-May-13 4:22 
AnswerRe: Can't run SC remotely to config service Pin
Alan N2-May-13 22:50
Alan N2-May-13 22:50 
GeneralRe: Can't run SC remotely to config service Pin
SledgeHammer013-May-13 4:08
SledgeHammer013-May-13 4:08 
GeneralRe: Can't run SC remotely to config service Pin
Alan N22-May-13 4:33
Alan N22-May-13 4:33 
QuestionRestoring Initial UI State Pin
Matt U.2-May-13 2:53
Matt U.2-May-13 2:53 
AnswerRe: Restoring Initial UI State Pin
Alan Balkany2-May-13 5:19
Alan Balkany2-May-13 5:19 
GeneralRe: Restoring Initial UI State Pin
Matt U.2-May-13 5:39
Matt U.2-May-13 5:39 
GeneralRe: Restoring Initial UI State Pin
Jasmine25012-May-13 7:10
Jasmine25012-May-13 7:10 
GeneralRe: Restoring Initial UI State Pin
Matt U.2-May-13 7:15
Matt U.2-May-13 7:15 
GeneralRe: Restoring Initial UI State Pin
Dave Kreskowiak2-May-13 11:06
mveDave Kreskowiak2-May-13 11:06 
GeneralRe: Restoring Initial UI State Pin
Jasmine25012-May-13 12:36
Jasmine25012-May-13 12:36 
GeneralRe: Restoring Initial UI State Pin
Dave Kreskowiak2-May-13 15:35
mveDave Kreskowiak2-May-13 15:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.