#85954 - 2002-06-05 07:00 PM
Re: LogonHours user properties
|
Anonymous
Anonymous
Unregistered
|
OK, I have come up with the following code. It rather inelegant and VERY slow, but it does work. It took nearly an hour to run against our domain. It does have the advantage of not modifying every single user account and therefore does not trigger full domain synchronisation.
code:
BREAK ON
$DefaultLevel=2
DIM $ValidTimes[3] DIM $TimeString[3]
$ValidTimes[0]='All' $ValidTimes[1]='Sunday 7:00 AM - 10:00 PM,Monday 7:00 AM - 10:00 PM,Tuesday 7:00 AM - 10:00 PM,Wednesday 7:00 AM - 10:00 PM,Thursday 7:00 AM - 10:00 PM,Friday 7:00 AM - 10:00 PM,Saturday 7:00 AM - 10:00 PM' $ValidTimes[2]='Sunday 7:00 AM - 8:00 PM,Monday 7:00 AM - 8:00 PM,Tuesday 7:00 AM - 8:00 PM,Wednesday 7:00 AM - 8:00 PM,Thursday 7:00 AM - 8:00 PM,Friday 7:00 AM - 8:00 PM,Saturday 7:00 AM - 8:00 PM'
$TimeString[0]='All' $TimeString[1]='Sunday-Saturday,07:00-22:00' $TimeString[2]='Sunday-Saturday,07:00-20:00'
CLS
AT(0,40) 'Process started at @TIME' ?
$Incorrect=0
$Domain=GETOBJECT('WinNT://RBSI') IF @ERROR=0 $Domain.Filter='User','' FOR EACH $User IN $Domain $Counter=$Counter+1 AT(1,40) 'Processed $Counter users' $Level=$DefaultLevel $Exclude=0 FOR EACH $Group IN $User.Groups SELECT CASE $Group.Name='Domain Admins' $Exclude=1 CASE $Group.Name='Exclusion Hours' $Level=0 CASE $Group.Name='Gibraltar Users' OR $Group.Name='LH Users' IF $Level>1 $Level=1 ENDIF ENDSELECT NEXT IF $Exclude=0 SHELL 'CMD /C NET USER "'+$User.Name+'" /DOMAIN>%Temp%\UserDetails.TXT' $Hours='' $Collect=0 IF OPEN(1,'%Temp%\UserDetails.TXT',2)=0 $Line=READLINE(1) DO IF SUBSTR($Line,1,LEN('Local Group Memberships'))='Local Group Memberships' $Collect=0 ELSE IF SUBSTR($Line,1,LEN('Logon hours allowed'))='Logon hours allowed' $Collect=1 ENDIF ENDIF IF $Collect AND LEN($Line)>0 IF $Hours<>'' $Hours=$Hours+',' ENDIF $Hours=$Hours+LTRIM(SUBSTR($Line,20,LEN($Line))) ENDIF $Line=READLINE(1) UNTIL @ERROR<>0 IF $Hours<>$ValidTimes[$Level] $Incorrect=$Incorrect+1 AT($Incorrect-1,0) COLOR r+/n $User.Name ' hours not correct' ? COLOR n/n AT(2,40) 'Found $Incorrect user' IF $Incorrect>1 's' ENDIF SHELL 'CMD /C NET USER "'+$User.Name+'" /TIMES:"'+$TimeString[$Level]+'" /DOMAIN>NUL' ENDIF $Result=CLOSE(1) ENDIF DEL '%Temp%\UserDetails.TXT' ENDIF NEXT ELSE 'Error @Error while opening object:' ? ' @SError' ? ENDIF
AT(3,40) 'Process completed at @TIME' ?
Sorry for the lack of comments. If anyone is wanting this I can go back and add them
|
|
Top
|
|
|
|
Moderator: Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
|
1 registered
(Allen)
and 675 anonymous users online.
|
|
|