SFImpersonator 
Author Message
 SFImpersonator

Here is a batch file and a  script I use for a RunAs command to open a
couple of program with my admin accounts. How would I incorporate them with
the SFImpersonator code from Craig Washington's site?

Batch File
%windir%\System32\runas.exe /user:domain1\-adm-%username% "mmc
%windir%\system32\dsa.msc

VBScript
wshshell.run "%windir%\system32\runas.exe /user:domain1\-adm-jerry
C:\WINNT\regedit.exe" , 1 , True

Thanks
Jerry



Thu, 17 Feb 2005 15:53:10 GMT  
 SFImpersonator
Jerry,

I haven't used SFIMpersonator, but here's what I can tell you.  I
grabbed Novell's notes on this, available from:
http://www.novell.com/coolsolutions/zenworks/features/trenches/tr_win2k_
profiles_zw.html

They include a couple of demo scripts.

Basically, here's how it works.  SFImpersonator has 2 methods,
Impersonate and RevertToSelf.  You call the Impersonate method,
supplying it with username, password, domain, and *type of
logon* -interactive, etc -.
As soon as the Impersonate is successfully called, the script is now in
the context of another user.

That means you just run the commands as you normally would in a script
after putting on your "Admin hat" via SFImpersonator.

Here's an example:

' SFImpersonator constants:
Const LOGON_INTERACTIVE = 2, LOGON_NETWORK = 3, _
 LOGON_BATCH = 4, LOGON_SERVICE = 5

domain = "domain1"
password = "mypassword
' Using your formula for username:
Set Net = CreateObject("WScript.Network")
username = "-adm-" & Net.UserName

Set SF = CreateObject("SFImpersonator.Impostor")

' we want interactive logon to use a GUI app...
SF.Impersonate username, password, domain, LOGON_INTERACTIVE

' We are now logged on as a new user within this script's process

' Run the app; no need to wait for it to complete
Set Sh = CreateObject("WScript.Shell")
Sh.Run "mmc %windir%\system32\dsa.msc", 1, False

' Now switch back to our own account before we exit.
' Note that the MMC window is still running as the admin account
SF.RevertToSelf

--
Please respond in the newsgroup so everyone may benefit.
http://dev.remotenetworktechnology.com


Quote:
> Here is a batch file and a  script I use for a RunAs command to open a
> couple of program with my admin accounts. How would I incorporate them
with
> the SFImpersonator code from Craig Washington's site?

> Batch File
> %windir%\System32\runas.exe /user:domain1\-adm-%username% "mmc
> %windir%\system32\dsa.msc

> vbscript
> wshshell.run "%windir%\system32\runas.exe /user:domain1\-adm-jerry
> C:\WINNT\regedit.exe" , 1 , True

> Thanks
> Jerry



Thu, 17 Feb 2005 17:43:46 GMT  
 SFImpersonator
Thanks Alex,

As soon as I get to work on Tuesday, I will give this a try. I run a lot of
applications with runas. I.E. , Exchange Admin, Outlook, Snap In's etc. and
will be interested to see how it works. I will post any final code as well.

Thanks again.



Quote:
> Jerry,

> I haven't used SFIMpersonator, but here's what I can tell you.  I
> grabbed Novell's notes on this, available from:
> http://www.novell.com/coolsolutions/zenworks/features/trenches/tr_win2k_
> profiles_zw.html

> They include a couple of demo scripts.

> Basically, here's how it works.  SFImpersonator has 2 methods,
> Impersonate and RevertToSelf.  You call the Impersonate method,
> supplying it with username, password, domain, and *type of
> logon* -interactive, etc -.
> As soon as the Impersonate is successfully called, the script is now in
> the context of another user.

> That means you just run the commands as you normally would in a script
> after putting on your "Admin hat" via SFImpersonator.

> Here's an example:

> ' SFImpersonator constants:
> Const LOGON_INTERACTIVE = 2, LOGON_NETWORK = 3, _
>  LOGON_BATCH = 4, LOGON_SERVICE = 5

> domain = "domain1"
> password = "mypassword
> ' Using your formula for username:
> Set Net = CreateObject("WScript.Network")
> username = "-adm-" & Net.UserName

> Set SF = CreateObject("SFImpersonator.Impostor")

> ' we want interactive logon to use a GUI app...
> SF.Impersonate username, password, domain, LOGON_INTERACTIVE

> ' We are now logged on as a new user within this script's process

> ' Run the app; no need to wait for it to complete
> Set Sh = CreateObject("WScript.Shell")
> Sh.Run "mmc %windir%\system32\dsa.msc", 1, False

> ' Now switch back to our own account before we exit.
> ' Note that the MMC window is still running as the admin account
> SF.RevertToSelf

> --
> Please respond in the newsgroup so everyone may benefit.
> http://dev.remotenetworktechnology.com



> > Here is a batch file and a  script I use for a RunAs command to open a
> > couple of program with my admin accounts. How would I incorporate them
> with
> > the SFImpersonator code from Craig Washington's site?

> > Batch File
> > %windir%\System32\runas.exe /user:domain1\-adm-%username% "mmc
> > %windir%\system32\dsa.msc

> > vbscript
> > wshshell.run "%windir%\system32\runas.exe /user:domain1\-adm-jerry
> > C:\WINNT\regedit.exe" , 1 , True

> > Thanks
> > Jerry



Thu, 17 Feb 2005 20:02:42 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Defrag without admin rights + SFImpersonator

2. SFImpersonator running called apps

3. sfImpersonator and RegOBJ.dll

4. SFImpersonator

5. SFImpersonator.dll

6. SFImpersonator running called apps

7. SFImpersonator Question

8. Sfimpersonator.dll - required privilege

9. sfimpersonator doesn't work ??

10. Required privilege using SFImpersonator.dll

11. Sfimpersonator error: required priviledge...

 

 
Powered by phpBB® Forum Software