Page 1 of 1 1
Topic Options
#144891 - 2005-08-05 05:40 PM Run script as another user
Mercury Offline
Fresh Scripter

Registered: 2005-06-21
Posts: 11
Hi guys,

I am writing a script that needs to update the time before attempting to join a domain (via sysprep). The problem is that if I just issue the Time command the local admin account doesn't have the domain privileges to access the time server or in this case any time server on the domain. I’m converting an existing Batch script that used the follwing technique to get around the problem:

Code:

rem ** Establish User permissions with rights on the xxx domain **

Net use \\%DOMAIN_CONTROLLER% %DOMAIN_USER_PASSWORD% /user:%CURRENT_DOMAIN%\%DOMAIN_USERNAME%

Cls

rem ** Set time **

Net TIME /DOMAIN:%CURRENT_DOMAIN% /Set



I have roughed up a KiXtart version of the same but have not tested it.. I suspect that it will not work.

Code:

; ** Establish User permissions with rights on the xxx domain **

Use "\\"+$DOMAIN_CONTROLLER /user:$LOGON_DOMIAN+"\"+$DOMAIN_USERNAME /password:$DOMAIN_USER_PASSWORD

CLS

; ** Set Time and Date**

SetTime $LOGON_DOMIAN



Is their an equivalent or more elegant method under KiXtart?

(running V4.5)

Top
#144892 - 2005-08-05 08:04 PM Re: Run script as another user
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Should work, but leaves your password in clear text unless you tokenize it.

That said, your use though of the USE command is missing what to map isn't it?

USE F: '\\DOMAIN\C$ /U:DOMAIN\AdminTypeAccount etc...

Set your time, then unmap the drive

Top
#144893 - 2005-08-05 08:26 PM Re: Run script as another user
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
No, it won't work cuz the quotes on the USE line are all wrong as is the concatenation.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#144894 - 2005-08-05 08:31 PM Re: Run script as another user
Mercury Offline
Fresh Scripter

Registered: 2005-06-21
Posts: 11
The lack of a specific drive letter or wildcard was deliberate with the batch script. The command completes without mapping anything and changes the current user for the “net time” and subsequent commands. I wanted to avoid mapping a share because I can't guarantee that the same share will be available on every time server in other geographical regions. All the time command requires is an authenticated domain user account - not access to the time server. One option I suppose would be to find or create a globally accessible share that won’t disappear in the near future but I was hoping to find a more elegant approach. Any ideas?
Top
#144895 - 2005-08-05 08:37 PM Re: Run script as another user
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
To get a SC to the DC, you can map to the IPC$.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#144896 - 2005-08-05 08:48 PM Re: Run script as another user
Mercury Offline
Fresh Scripter

Registered: 2005-06-21
Posts: 11
Hi Les,

This is literally my first attempt at KiXtart scripting and I thought translating a 450 line batch script would be a good practical exercise

Where did I screw up?

Top
#144897 - 2005-08-05 09:54 PM Re: Run script as another user
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Was in a hurry so didn't post FULL line, but thought he would get the idea.

Though mapping to the IPC$ might not be sufficient as it is only for Inter Process Communications between certain processes. In the past I know that some things won't work with only the IPC$ mapped, but your milage may vary.
 

Top
#144898 - 2005-08-06 12:49 AM Re: Run script as another user
Mercury Offline
Fresh Scripter

Registered: 2005-06-21
Posts: 11
I will experiment..thanks guys
Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1386 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.054 seconds in which 0.026 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org