WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

wNT
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

wntRunAsUser Function Problems

Keywords: 	  wntRunAsUser

Question:

I am having problems with this function. No matter what I do I get the error "Privilege 'Act as part of operating system' not held".I have been through everything I can find on this site with reference to wntRunAsUser and as far as I can see have done everything required. I have checked..
  1. I am logging in to a Domain with a Domain User account.
  2. In User Manager for Domains I have given the user account the user rights..
    • Act as part of O/S
    • Increase Quotas
    • Replaced Process Level Token

  3. Domain Admins is a member of the local Adminstrator group.
  4. Domain Users is a member of the local User group.
This is the code I am running..

(The UserName and Password are replaced with a Domain Admin Account)

   AddExtender("WWWNT34I.DLL")
   UserName = "xxxx"
   UserPWD = "xxxx"
   UserDomain = "UK"
   Process = "Q:\MCWS32.NEW\Setup.exe"
   RetVal = wntRunAsUser(UserDomain,UserName,UserPWD, 2, 0)
   Run(Process, "")
Even if I run the script whilst I am logged in I get the same error, and I am a Domain Admin. I am very keen to get this working, it will solve a BIG headache for us! Any help/advice would be much appreciated.

Answer:

  1. In the NT Resource kit is a similiar SU utility that needs the *exact* same permissions wntRunAsUser does. If you get SU running, then wntRunAsUser should work too.

  2. You need to add those rights to each of the NT workstation clients. We grant those rights to Domain Users on each client workstation.

  3. In the documentation for wntrunasuser it states that 0 = only wbt program and 1 = all child processes. So, if you modify:
       RetVal = wntRunAsUser(UserDomain,UserName,UserPWD, 2, 0)
    
    to
       RetVal = wntRunAsUser(UserDomain,UserName,UserPWD, 2, 1)
    
    it should work.

Question (cont'd):

First off, thanks for the feedback. I think I am nearly there!

I added the required user rights to Domain Users via the User Manager on the local workstation and this now seems to have got past the initial problem.

I also changed the last flag for wntRunAsUser to 1 as suggested.

The problem I have now is a little strange. If I simply use the Run command in the script, i.e.

   Run("c:\install\setup.exe", "")
The setup runs OK but fails (obviously) due to lack of user rights. However if I include the rest of the script, as in..
   AddExtender("WWWNT34I.DLL")
   UserName = "xxx"
   UserPWD = "xxx"
   UserDomain = "UK"
   RetVal = wntRunAsUser(UserDomain, UserName, UserPWD, 2, 1)
   Run("c:\install\setup.exe", "")
.. Noting actually happens when it reaches the Run command. I added the DEBUG(@ON) option, and wntRunAsUser returns a value of 1, as does the Run command, but noting happends?! Any ideas anyone?

Answer:

Well, for starters, try running notepad.exe instead of setup.exe to see if that works.

Otherwise I suspect some kind of weird environment issue.


wntGetCon and wntRunAsUser

Question:

It appears that the wntGetCon function stops working after the wntRunAsUser function has been executed. Have you seen this before? TIA!
AddExtender("WWWNT34I.DLL") ;Add required Network Extender Module

;Define Impersonation parameters for wntRunAsUser
domain=""
user=""
password=""

errormode(@off)
impersonate = wntRunAsUser(domain, user, password, 2, 0) ;Start impersonating a local administrator
errormode(@cancel)

wdrive = wntGetCon("W:") ;find out what W: is connected to.
pdrive = wntGetCon("P:") ;find out what P: is connected to. 

Answer:

Well, we've seen where when sometimes you change to a different user, you get that users privileges and sometimes they do not have sufficient privileges. A lot of local Admin accounts do NOT have network privileges. Check carefully.
Article ID:   W14270
Filename:   wntRunAsUser Function - 2.txt
File Created: 2001:03:01:14:20:18
Last Updated: 2001:03:01:14:20:18