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..This is the code I am running..
- I am logging in to a Domain with a Domain User account.
- 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
- Domain Admins is a member of the local Adminstrator group.
- Domain Users is a member of the local User group.
(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:
- 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.
- You need to add those rights to each of the NT workstation clients. We grant those rights to Domain Users on each client workstation.
- 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)toRetVal = 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: W14270Filename: wntRunAsUser Function - 2.txt