Page 1 of 1 1
Topic Options
#121759 - 2004-06-24 12:23 AM Add Domain Group to Local Group
chmod Offline
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
#121760 - 2004-06-25 09:55 AM Re: Add Domain Group to Local Group
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Why would you want to circumvent the Security of all these machines by plaacing the Domain Users group into the Power Users group ?

Do you have some valid reason for this ?

I'm sure we can help you to accomplish this goal, but a better understanding of Security for you might be a better choice.

I know that AutoCAD has issues if the user is not a Power User, but then only AutoCAD users should be Power Users, not Domain Users, this is one small notch down from being Administrator.

By having Domain Users members of the Power Users group on all workstations allows Virus/Worms/and Trojans to spread much more rapidly. Potentially bringing your Network to its knees.

Top
#121761 - 2004-06-25 04:42 PM Re: Add Domain Group to Local Group
chmod Offline
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
#121762 - 2004-06-27 04:06 AM Re: Add Domain Group to Local Group
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
This could and should all be done via admin scipts and not during login.
_________________________
There are two types of vessels, submarines and targets.

Top
#121763 - 2004-06-27 09:57 AM Re: Add Domain Group to Local Group
chmod Offline
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 Offline
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
#121765 - 2004-06-28 04:43 AM Re: Add Domain Group to Local Group
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Ah, we finally get some detailed info. If you'd have read and followed the "ABC's of KiXtart board etiquette and message to new forum users " FAQ and provided more detailed information you'd have gotten a suitable answer earlier.

The main issue is that you want to use KiXforms as part of the login script. This requires KiXforms to be registered on the local machine. However, it does not require users to be more than regular users on the local computers.

There are two ways to distribute KiXforms. The (IMHO) recommended way is via admin script as this can both deploy the initial KiXforms DLL as well as distribute updated versions. You basically create a script that distributes the DLL to all computers via COPY to the remote admin share if necessary in the network from a central location and then issues a Scheduled Task under an administrative account that unregisters/re-registers the DLL. As a backup method, the login script could contain an administrative section that updates and re-registers the KiXforms DLL when logging in under an administrative account. All these methods are already described in detail on both the KiXtart and KiXforms BBSes and demonstrate secure practices.


Edited by sealeopard (2004-06-30 04:35 AM)
_________________________
There are two types of vessels, submarines and targets.

Top
#121766 - 2004-06-29 05:29 AM Re: Add Domain Group to Local Group
chmod Offline
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
#121767 - 2004-06-30 04:41 AM Re: Add Domain Group to Local Group
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA

Quote:

The best way is the cheapest and fastest


I'm not sure how to read your post. What I am suggesting follows standard PC management procedures in a secure network environment. The cheapest way is only then the cheapest way if nothing adverse happens. A proper risk assessment should point out that a properly secured network is cheaper than saving a couple of minutes of work by not coding/deploying the DLL via a central admin script.
_________________________
There are two types of vessels, submarines and targets.

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
1 registered (Henriques) and 2516 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.093 seconds in which 0.066 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