#121759 - 2004-06-24 12:23 AM
Add Domain Group to Local Group
|
chmod
Fresh Scripter
Registered: 2004-06-01
Posts: 24
Loc: Sacramento, CA
|
I need to be able to add the domain group "Domain Users" to the local machine's "Power Users" group. I tried it this way.. but I can get it to work. Can anyone help me on this?
Code:
;**************************************************
;*** Check if domain group is in local group
;**************************************************
$grouptoadd = @DOMAIN + "\Domain Users"
$obj = GetObject("WinNT://" + @WKSTA + "/Power Users")
$obj.filter = "group",""
Dim $DomainGroups[0]
For Each $GroupObj In $Obj.Members
If Split($groupobj.adspath,"/")[3] <> @WKSTA
$DomainGroups[$i] = Split($groupobj.adspath,"/")[2] +"\" + Split($groupobj.adspath,"/")[3]
$i = $i + 1
ReDim preserve $DomainGroups[$i]
EndIf
Next
;**************************************************
;*** If domain group is not in local group, add it
;**************************************************
If AScan($DomainGroups,$GroupToAdd) = -1
? $groupToAdd + " was not found in " + SubStr($obj.adspath,14,7) + "\" + SubStr($obj.adspath,22,18)
$PdcName = @DOMAIN
$ComputerName = @WKSTA
$UserString = "Domain Users"
$GroupString = "Power Users"
;? $PdcName + " " + $ComputerName + " " + $UserString + " " + $GroupString
$GroupObj = GetObject("WinNT://" + $PdcName + "/" + $ComputerName + "/" + $GroupString)
$GroupObj.Add ("WinNT://" + $PdcName + "/" + UserString)
$DomainObj = ""
$GroupObj = ""
Exit 0
Else
? "Added " + $groupToAdd + " to " + SubStr($obj.adspath,14,7) + "\" + SubStr($obj.adspath,22,18)
EndIf
|
|
Top
|
|
|
|
#121761 - 2004-06-25 04:42 PM
Re: Add Domain Group to Local Group
|
chmod
Fresh Scripter
Registered: 2004-06-01
Posts: 24
Loc: Sacramento, CA
|
We are migrating from Windows 2000 to XP and we need the local user to have at least Power User rights when logging in, so we can push packages in prep for the rollout and the new kix login (such as registering kixforms.dll) script in a few weeks. Our 2000 boxes are locked down pretty tight for a normal user...
|
|
Top
|
|
|
|
#121763 - 2004-06-27 09:57 AM
Re: Add Domain Group to Local Group
|
chmod
Fresh Scripter
Registered: 2004-06-01
Posts: 24
Loc: Sacramento, CA
|
Quote:
This could and should all be done via admin scipts and not during login.
Well, since I am just the "help" and not the "boss" I can't make that decision. lol They want their NEW GUI login script and they want now. So, I must register the kixforms.dll before it tries to open the logon.kix/form - The only way I can do this is via a batch file which is run before the logon.kix runs. The 2000 boxes are locked down for the normal users, so regsvr32 will not work for them, unless they're access level is at least "Power Users" - So they want the domain group "Domain Users" added to the local machine "Power Users" group. Can this be done with Kix or not?
Also note, we are not running AD and these 2000 boxes will all be migrated with-in 3 weeks...
|
|
Top
|
|
|
|
#121764 - 2004-06-27 10:40 AM
Re: Add Domain Group to Local Group
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11634
Loc: Space
|
Hi ChMod,
I still say you should speak with Management and at least express your concerns as this is against good security policies. NO, you can not do it during logon unless the user already has Administrator or Power User rights on the system, that is why it must be done as a remote Administrative script.
None the less, yes it CAN be done with KiXtart.
This script requires KiXtart v4.22 being run from an account that has Administrative rights on the workstations already.
First you need to get a list of all the workstations. You can probably use one of these UDFs to get the list.
NetView2() - Enumerate all computers in your domain
http://www.kixtart.org/ubbthreads/showflat.php?Cat=&Number=82503
COMNetView() - Enumerate all computers in your domain
http://www.kixtart.org/ubbthreads/showflat.php?Cat=&Number=82500
Then strip out any Servers or other computers you want to exclude.
Then run this script ... (modify the portions that apply to your information). It will check the list of computers supplied and ping to see if they are online, if they are found online it will add the Domain Users to the Power Users group on the system.
NOTE: This will not work though for foreign language OS as the group names will not be valid.
Howard Bullock though may have something to get around that if you need it.
GrpMaint.exe (756K) Ver: 0.9.2.2
http://home.comcast.net/~habullock/Perlutilities.htm
http://home.comcast.net/~habullock/Library/GrpMaint.exe
If you simply want to register KiXforms.dll on the systems you could also run this UDF and not modify the Security Groups on the systems.
RemoteExec() - execute a process on remote PCs
http://www.kixtart.org/ubbthreads/showflat.php?Cat=&Number=83206
Code:
Break On
Dim $SO
$SO=SetOption('Explicit','On')
$SO=SetOption('NoVarsInStrings','On')
Dim $System,$Systems,$CloseFile,$Results,$Results1,$Results2,$Results3,$Status,$AddTo
$Systems=ReadFile('C:\REPORTS\PowerUsers.txt')
For Each $System in $Systems
If $System
$Results = Join(wshpipe("ping " + $System + " -n 1",1),@CRLF)
$Results1 = Split(Split($Results,":")[2],"=")[0]
$Results2 = Split(Split($Results,"for")[1],":")[0]
$Results3 = Split(Split($Results,"from")[1],":")[0]
Select
Case (SubStr($Results,20,3)="not")
$Status=$System+'*'+'No DNS Entry'+'*'+'*' ; Not found in DNS
? $Status
Case (SubStr($Results1,2,5)="bytes")
$AddTo=AddToLocalAdmin($System,'Power Users','your domain','Domain Users')
$Status=$System+'*'+'Online'+'*'+$Results3+' Add Group: ' + $AddTo
? $Status
Case 1
$Status=$System+'*'+'Offline'+'*'+$Results2 ; Has an IP in DNS
? $Status
EndSelect
EndIf
Next
Function WshPipe($ShellCMD, OPTIONAL $NoEcho)
Dim $oExec, $Output
$oExec = CreateObject("WScript.Shell").Exec($ShellCMD)
If Not VarType($oExec)=9 $WshPipe="WScript.Shell Exec Unsupported" Exit 10 EndIf
$Output = $oExec.StdOut.ReadAll + $oExec.StdErr.ReadAll
If Not $NoEcho $Output Endif
$WshPipe=Split(Join(Split($Output,CHR(13)),''),CHR(10))
Exit($oExec.ExitCode)
EndFunction
Function ReadFile($file)
Dim $lf, $f, $_, $t
$lf=Chr(10)
$f=FreeFileHandle
$_=Open($f,$file)
If @ERROR Exit @ERROR EndIf
Do $t=$t+$lf+ReadLine($f) Until @ERROR
$_=Close($f)
$ReadFile=Split(SubStr($t,2),$lf)
EndFunction
Function AddToLocalAdmin($Computer,$GroupToAddTo,$Domain,optional $GroupToAdd,optional $AccountToAdd)
Dim $Group,$User,$Admin,$Err
$Group = GetObject('WinNT://' + $Computer + '/' + $GroupToAddTo + ',group')
If $GroupToAdd<>""
$User = GetObject('WinNT://' + $Domain + '/' + $GroupToAdd + ',group')
EndIf
If $AccountToAdd<>""
$User = GetObject('WinNT://' + $Domain + '/' + $AccountToAdd + ',user')
EndIf
$Group.Add($User.ADsPath)
$Err = @ERROR
$AddToLocalAdmin=$Err
EndFunction
Function fnCOMErr($lErr)
If $lErr<0 $lErr=VAL("&"+Right(DecToHex($lErr),4)) EndIf
Exit $lErr
EndFunction
|
|
Top
|
|
|
|
#121766 - 2004-06-29 05:29 AM
Re: Add Domain Group to Local Group
|
chmod
Fresh Scripter
Registered: 2004-06-01
Posts: 24
Loc: Sacramento, CA
|
Wow, that was very nice of you NTDOC, thank you! I really appreciate it, I should be able to come up with a solution based on this.
Jens, The company I work for is a "Government/City" agency, and trying to explain things and get them to "CHANGE" is like pulling teeth from a piranha, there's too many and it's not going to happen. The best way is the cheapest and fastest.
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(Henriques)
and 2516 anonymous users online.
|
|
|