Page 1 of 1 1
Topic Options
#74164 - 2003-03-24 10:17 PM Can anyone help me with this code?
DJ Ballistic Offline
Starting to like KiXtart

Registered: 2003-02-21
Posts: 185
Awhile back someone created this utility if you will that will query the active directory of my domain and automatically assign logon.bat to each user in a particular OU. It works perfectly, however, in case something goes sour after we deploy this is there a way to change something in the code and run it again on that OU to remove the logon.bat entry under profile for the user.

Here is the code:

code:
   

Break ON
$rc=SetOption('WrapAtEOL','ON')

; uncomment the next line to step through the code
; Debug ON
; Example of LDAP call. GetObject("LDAP://ou=Users,ou=YourBusinessUnit,dc=YourCompany,dc=com")
; You need to know your LDAP connection. You can maybe find it by checking the propery details on the OU for your users.
$target = GetObject("LDAP://OU=Test,OU=AdminBldg,DC=sussexcounty,DC=net")
? 'Error = '+@ERROR+' - '+@SERROR
$loginscript="Logon.bat"
For Each $user in $target
? 'checking user: '+$user.name
$script = $user.loginscript
$loginscripterror = @error
? "Logon script error: @error - @serror"
? 'assigned login script: '+$script
If $Script <> $loginscript OR $loginscripterror
? "Current Script for " +$user.name " is: " +$script+ " Should be: " +$loginscript
$user.loginscript=$loginscript ; Remove the semi-colon at the front of this line to enable actually resetting the logon bat.
? 'Error = '+@ERROR+' - '+@SERROR
$user.SetInfo ; Remove the semi-colon at the front of this line to enable actually resetting the logon bat.
? 'Error = '+@ERROR+' - '+@SERROR
? "Changed current Script for " +$user.name " to: " +$user.loginscript
EndIf
Next
? 'If no user was displayed, then no user was retrieved from the OU'

Sleep 2


Top
#74165 - 2003-03-24 10:24 PM Re: Can anyone help me with this code?
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Just assign an empty logonscript entry.

[ 24. March 2003, 23:05: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#74166 - 2003-03-24 11:29 PM Re: Can anyone help me with this code?
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Just out of curiousity, I ran the script to check this out.. If there is an error, it never gets reset..

code:
 BREAK ON
$rc=SetOption('WrapAtEOL','ON')

; uncomment the next line to step through the code
; Debug ON
; Example of LDAP call. GetObject("LDAP://ou=Users,ou=YourBusinessUnit,dc=YourCompany,dc=com")
; You need to know your LDAP connection. You can maybe find it by checking the propery details on the OU for your users.
$target = GetObject("LDAP://OU=Test,OU=AdminBldg,DC=sussexcounty,DC=net")
? 'Error = '+@error+' - '+@serror
$loginscript="ntlogon.bat"
FOR EACH $user IN $target
? 'checking user: '+$user.name
$script = $user.loginscript
? 'assigned login script: '+$script
IF @error <> O
$loginscripterror = @error
? "Logon script error: @error - @serror"
IF $script <> $loginscript OR $loginscripterror
? "Current Script for " +$user.name " is: " +$script+ " Should be: " +$loginscript
;;$user.loginscript=$loginscript ; Remove the semi-colon at the front of this line to enable actually resetting the logon bat.
;;? 'Error = '+@error+' - '+@serror
;;$user.SetInfo ; Remove the semi-colon at the front of this line to enable actually resetting the logon bat.
;;? 'Error = '+@error+' - '+@serror
;;? "Changed current Script for " +$user.name " to: " +$user.loginscript
ENDIF
$loginscripterror = 0
SLEEP 2
ENDIF
NEXT

HTH,

Kent

[ 24. March 2003, 23:36: Message edited by: kdyer ]
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#74167 - 2003-03-24 11:37 PM Re: Can anyone help me with this code?
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Kent,

That's true, but if you go back and check the nearly 200 posts from the origianl topic, you'll find that Howard provided him some updated code that does reset the error codes. It was just not posted here.

Top
#74168 - 2003-03-24 11:41 PM Re: Can anyone help me with this code?
Kdyer Offline
KiX Supporter
*****

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

Understood..

It was just something that I wanted to try as I may have a need for this coming up soon.

[Smile]

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

Top
#74169 - 2003-03-25 08:02 PM Re: Can anyone help me with this code?
DJ Ballistic Offline
Starting to like KiXtart

Registered: 2003-02-21
Posts: 185
I can't find the code now that has it reset. I tried assigning a blank logon script and it won't take it.
Top
#74170 - 2003-03-25 08:07 PM Re: Can anyone help me with this code?
DJ Ballistic Offline
Starting to like KiXtart

Registered: 2003-02-21
Posts: 185
Oh yes got the code to take the logon.bat assignment back out by
adding this after the =""
That removed the script assignment. I still cannot find the thread where there was code posted about if there were errors to reset. I thought I had all of the code that was posted by Howard on this issue.

Top
#74171 - 2003-03-25 08:11 PM Re: Can anyone help me with this code?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
It should not be hard to find your own posts! Check your profile:
http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_profile;u=00007029

View Recent Posts:
http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=recent_user_posts;u=00007029
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#74172 - 2003-03-25 08:27 PM Re: Can anyone help me with this code?
DJ Ballistic Offline
Starting to like KiXtart

Registered: 2003-02-21
Posts: 185
OK I have been through the old posts and what NTDOC posted is the same that I have. I don't see anywhere that there is a place to have it reset if an error occurs.
Here is the code from NTDOC's post.

code:
BREAK ON
; Example of LDAP call. GetObject("LDAP://ou=Users,ou=YourBusinessUnit,dc=YourCompany,dc=com")
; You need to know your LDAP connection. You can maybe find it by checking the propery details on the OU for your users.
$target = GetObject("LDAP://your LDAP details")
$loginscript="yourlogon.bat"
for each $user in $target
if $user.loginscript <> "$loginscript"
? "Current Script for " +$user.name " is: " +$user.loginscript+ " Should be: " +$loginscript
; $user.loginscript=$loginscript ; Remove the semi-colon at the front of this line to enable actually resetting the logon bat.
; $user.SetInfo ; Remove the semi-colon at the front of this line to enable actually resetting the logon bat.
endif
next


Top
#74173 - 2003-03-25 08:31 PM Re: Can anyone help me with this code?
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
I have been silent...
as I don't know what error condition you are talking about!

what you mean with error condition?
_________________________
!

download KiXnet

Top
#74174 - 2003-03-25 08:32 PM Re: Can anyone help me with this code?
DJ Ballistic Offline
Starting to like KiXtart

Registered: 2003-02-21
Posts: 185
Actually at any rate i figured out how to make the result null for the logon script and it works now.
Top
#74175 - 2003-03-25 09:06 PM Re: Can anyone help me with this code?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
DJ,
Is english a second language for you? NTDOC said "Howard provided him some updated code that does reset the error codes" so why would you be looking for an update from NTDOC?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#74176 - 2003-03-26 06:52 AM Re: Can anyone help me with this code?
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
I wrote the original code myself a long time ago to work on our system. Howard noticed that it might be possible for an error to occur which might prevent a proper update.

Apparently you did not understand DJ as Jens explained to you already in the first reply to set it to a blank entry. KiXtart does this by using either '' or "" If you were not sure what Jens was talking about, you should have posted and asked more specifically what he meant.

Howard modified my code a little.
It is posted here.
http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=2;t=004215;p=5

Essentially the code is:



Break ON
; uncomment the next line to step through the code
; Debug ON
$target = GetObject("LDAP://OU=Test,OU=Information Systems,OU=AdminBldg,DC=sussexcounty,DC=net")
? 'Error = '+@ERROR+' - '+@SERROR
$loginscript="logon.bat"
For Each $user in $target
  ? 'checking user: '+$user.name
  $script = $user.loginscript 
  ? 'Logon script error: @error - @serror'
  ? 'assigned login script: '+$script
  If $Script <> $loginscript
    ? "Current Script for " +$user.name " is: " +$script+ " Should be: " +$loginscript
    $user.loginscript=$loginscript
     ? 'Error = '+@ERROR+' - '+@SERROR
    $user.SetInfo
     ? 'Error = '+@ERROR+' - '+@SERROR
     ? "Changed current Script for " +$user.name " to: " +$user.loginscript
  EndIf
Next
? 'If no user was displayed, then no user was retrieved from the OU'
 


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 2175 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.065 seconds in which 0.026 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