Page 1 of 1 1
Topic Options
#134629 - 2005-02-25 10:56 PM I am missing something here..
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Code:

BREAK ON
CLS
$groupobj = GetObject("WinNT://" + @ldomain + "/Domain Users")
FOR EACH $userobj IN $groupobj.members
$userobj = GetObject("WinNT://DCSERVER/"+$userobj.name)
IF INSTR('"'+$userobj.loginscript+'"','NEWSCRIPT')
?$userobj.name+','+$userobj.fullname
;?$userobj.loginscript
$UserObj.LoginScript = "wkix32 newscript\kixtart.kix"
$UserObj.SetInfo
$UserObj = Nothing
ENDIF
;UserObj.LoginScript = "Login script file name"
;UserObj.SetInfo
;$UserObj = Nothing

NEXT
?'process is complete.. press a key'
GET $



It works fine.. However, when it gets to the last user, it comes up with:
Quote:


ERROR : invalid method/function call: missing required parameter 2!
Script: C:\!Kix\TEST.KIX
Line : 6





Thanks,

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#134630 - 2005-02-25 11:24 PM Re: I am missing something here..
MightyR1 Offline
MM club member
*****

Registered: 1999-09-09
Posts: 1264
Loc: The Netherlands
Kent,

try to see what the last username's name is by adding a $userobj.name ? after the GETOBJECT and before the IF.

My guess is the last entry in $groupobj.members is a "wrong" user...



_________________________
Greetz,
Patrick Rutten

- We'll either find a way or make one...
- Knowledge is power; knowing how to find it is more powerful...
- Problems don't exist; they are challenges...

Top
#134631 - 2005-02-26 12:17 AM Re: I am missing something here..
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Try not to reassign a new value to the $userobj value inside the FOR loop.
_________________________
There are two types of vessels, submarines and targets.

Top
#134632 - 2005-02-26 12:45 AM Re: I am missing something here..
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Why all the quotes as in:
'"'+$userobj.loginscript+'"'

Try without quotes.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#134633 - 2005-02-26 12:47 AM Re: I am missing something here..
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Also, I doubt "nothing" is valid in KiX.
$UserObj = ""
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#134634 - 2005-02-26 12:55 AM Re: I am missing something here..
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Sheesh.. This is a converted script from http://cwashington.netreach.net .. I should know better!

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#134635 - 2005-02-27 08:09 AM Re: I am missing something here..
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Here is the corrected code:
Code:

Break ON
CLS
$groupobj = GetObject("WinNT://"+@ldomain+"/Domain Users")
For Each $userobjg in $groupobj.members
$userobj = GetObject("WinNT://<YOUR DC>/"+$userobjg.name)
If InStr($userobjg.loginscript,'NEWSCRIPT')
?$userobjg.name+','+$userobjg.fullname
;?$userobj.loginscript
$UserObjg.LoginScript = "wkix32 newscript\kixtart.kx"
$UserObjg.SetInfo
$UserObjg=""
EndIf
$userobjg.name=""
Next
?'process is complete.. press a key'
Get $



If you want to set all Domain Users, you can do:
Code:

Break ON
CLS
$groupobj = GetObject("WinNT://"+@ldomain+"/Domain Users")
For Each $userobjg in $groupobj.members
$userobj = GetObject("WinNT://<YOUR DC>/"+$userobjg.name)
?$userobjg.name+','+$userobjg.fullname
$UserObjg.LoginScript = "wkix32 newscript\kixtart.kx"
$UserObjg.SetInfo
$UserObjg=""
EndIf
$userobjg.name=""
Next
?'process is complete.. press a key'
Get $



You can replace:
wkix32 newscript\kixtart.kx

With:
ntlogon.bat

Thanks,

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#134636 - 2005-02-27 03:42 PM Re: I am missing something here..
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Since our divisions have their own OUs and we delegate admin rights to DivIT, we use a slightly different approach. We use the LDAP method and base it on OU.

$users = GetObject("LDAP://ou=Users,ou=bla,ou=bla,dc=domain,dc=local")

This would return all objects but a filter can be set for user.

There is also the ADODB method with the "ADsDSOObject" that is really fast but involves a lot more code.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
Page 1 of 1 1


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

Who's Online
0 registered and 857 anonymous users online.
Newest Members
JimDunn, fgarcia, Viginette, ManuvdWielNL, Sir_Barrington
17890 Registered Users

Generated in 0.058 seconds in which 0.023 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