Page 1 of 1 1
Topic Options
#140514 - 2005-05-28 12:19 AM Help with FAQ code for replacing LOGON text in User Profiles
Huffinagle Offline
Getting the hang of it
*****

Registered: 2002-09-04
Posts: 75
Loc: McMinnville, OR, USA
How can I get the following code to work in my environment?
Windows 2000 Active Directory.
The code in red are my personalized information.

I've run the code and received the message, "script complete" but the test user profile wasn't modified.

Code:
 

CLS
BREAK ON
$DomainString='MCMINNVILLE'
$GroupString='ISTEST'
$GroupObj = GetObject('WinNT://' + $DomainString + '/' + $GroupString)
For each $UserObj in $GroupObj.Members
;-Look for the word NTLOGON in case of NTLOGON OR NTLOGON.BAT
IF $UserObj.AccountDisabled<>'True' AND INSTR($UserObj.LoginScript,'NTLOGON')
?$UserObj.Name
?$UserObj.FullName
$UserObj.LoginScript = 'WKIX32.EXE KIXTART.KIX'
$UserObj.SetInfo
$error=@error
$logshare='H:'
$logfile=$logshare+'\'+$DomainString+'CHANGESCRIPT.CSV'
$logdata=$UserObj.Name+','+$UserObj.FullName+','+$error+@CRLF
LOGGER($logfile,$logdata)

ENDIF
Next
?'--'
?'Script complete'
SLEEP 4

FUNCTION LOGGER($logfil,$logdat)
$result=0
$n=0
DO
$result=Open(1, $logfil, 5)
IF $result<>0
IF $n=0
;First wait
?'Please wait'
ELSE
;follow waits
'.'
ENDIF
SLEEP 3
ELSE
$result=WriteLine(1, $logdat)
$result=Close(1)
ENDIF
$n=$n+1
UNTIL $result=0 OR $n=5
ENDFUNCTION


Also, it looks like there is a FUNCTION creating a log file. Where is this log file being created?
Original FAQ Link

Top
#140515 - 2005-05-28 01:05 AM Re: Help with FAQ code for replacing LOGON text in User Profiles
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Does your existing BATch file include "NTLOGON" in its name?

I prefer to use the LDAP provider and modify based on OU.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#140516 - 2005-06-07 02:19 AM Re: Help with FAQ code for replacing LOGON text in User Profiles
Huffinagle Offline
Getting the hang of it
*****

Registered: 2002-09-04
Posts: 75
Loc: McMinnville, OR, USA
Les,

I think I understand what you are saying. I need to replace NTLOGON with the text that is currently in my user account logonscript field. Is that correct? Currently, the BATch file name is login1.bat.

Would I then replace NTLOGON with login1.bat in the UDF? You also mentioned an LDAP string. Can you give me an example?

Thanks, Matt

Top
#140517 - 2005-06-07 02:47 AM Re: Help with FAQ code for replacing LOGON text in User Profiles
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Yes, you need to put login1.bat in place of NTLOGON for that code to work.

In my organization, each OU has their own admin staff so when we migrated them to AD, we set their logon script only for their OU.
Code:

BREAK ON
$users = GetObject('LDAP://ou=Users,ou=bla,ou=bla,dc=yada,dc=local')
$Users.filter = Split('user')
$loginscript = 'WKIX32.EXE KIXTART.KIX'
for each $user in $users
if $user.scriptpath <> $loginscript
? "Current Script for " + $user.name " is: " + $user.scriptpath + " Modified to " + $loginscript
;$user.scriptpath = $loginscript
;$user.SetInfo
endif
next


you must remove the two semicolons for the script to commit the change.
_________________________
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:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 271 anonymous users online.
Newest Members
Sir_Barrington, batdk82, StuTheCoder, M_Moore, BeeEm
17886 Registered Users

Generated in 0.087 seconds in which 0.046 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