Page 1 of 1 1
Topic Options
#194201 - 2009-06-10 03:10 PM IF Ingroup
ares4life Offline
Fresh Scripter

Registered: 2009-06-06
Posts: 6
Loc: VT
Hello All,

My script is having a small problem. I havespecial share for Admins only, and i want it so if the user is in DOmain admins,they can get the share added. However, Domain Users are being added this share as well.

 Code:
;  KIXTART.SCR
;
;  KiXtart sample default logon script
;
;  Note :  This code sample is provided for demonstration purposesonly.
;          Microsoft makes no warranty, either express or implied,
;          as to its usability in any given situation.
;
;   Copyright (C) 2001 Ruud van Velsen.
;   All rights reserved.
;
CLS

small
Color b+/n
BOX (0,0,24,79,GRID)            ; 'background grid'
Color b/n
BOX (8,21,18,61,Å)              ; 'shadow' of the box'
Color g+/n
BOX (3,20,20,65,FULL)

Color w+/n
IF ((@time > "00:00:00") AND (@time < "12:00:00"))
at (5,22) "Good Morning @fullname,"
ELSE
IF ((@time >= "12:00:00") AND (@time < "18:00:00"))
at (5,22) "Good Afternoon @fullname,"
ELSE
at (5,22) "Good Evening @fullname,"
ENDIF
ENDIF

at (7,22) "Please Wait For Logon script Execution"
AT ( 9,25) "Userid       : "    ; display some text strings
AT (10,25) "Full name    : "
AT (11,25) "Privilege    : "
AT (12,25) "Workstation  : "
AT (13,25) "Domain       : "
AT (14,25) "Logon Server : "

Color y+/n
AT ( 9,40) @userid              ; ...and some macro's
AT (10,40) @fullname
AT (11,40) @priv
AT (12,40) @wksta
AT (13,40) @domain
AT (14,40) @lserver

Color w/n
$userdir=@userid + $$ ;
settime "\\PDC"

; Mount general shares for staff
;

use Z: "\\bdc\staffshares" /PERSISTENT:NO
use H: "\\bdc\$userdir" /PERSISTENT:NO


IF INGROUP("Domain Users")  
  If AddPrinterConnection("\\print\hp4100n") = 0
		? AT (16,25) "Added printer connection to printer."
	EndIf
	
; Set Default Printer
;
$rc=SetAsDefaultPrinter("\\print\hp4100n")

function SetAsDefaultPrinter($printer)
  $SetAsDefaultPrinter=1
  if setdefaultprinter($printer)=0
    $SetAsDefaultPrinter=0
  else
    dim $PrintServer,$PrintQueue[0],$sharedprinter,$rc,$server
    $PrintQueue[0]="PrintQueue"
    if instr($printer,"\\") 
      $server=split($printer,"\")[2]
      $printer=split($printer,"\")[3]
    else
      $server=@wksta
    endif
    $PrintServer=GetObject("WinNT://" + $server + ",computer")
    if @error
      exit @error
    else
    $Printserver.filter=$PrintQueue   
    for each $sharedprinter in $printserver
      if $sharedprinter.name=$printer
        $rc=setdefaultprinter($sharedprinter.printername)
        if $rc=0
          $SetAsDefaultPrinter=0
          exit 0
        else
          $SetAsDefaultPrinter=$rc
          exit @error
        endif
      endif
    next
  endif 
endfunction
ENDIF



; If within the Domain Admins Group
; Set the AdminFiles share

IF INGROUP("Domain Admins") 

 use X: "\\bdc\adminfiles" /PERSISTENT:NO

ENDIF

sleep 4 ;
AT (18,25) "Logon complete. Closing application"
sleep 10 ;
exit
 


Edited by ares4life (2009-06-10 05:19 PM)

Top
#194202 - 2009-06-10 03:13 PM Re: IF Ingroup [Re: ares4life]
ares4life Offline
Fresh Scripter

Registered: 2009-06-06
Posts: 6
Loc: VT
Is my code wrong somewheres, should i redo it? i know it may look a bit messy. I am new at this and trying to make it all work.
Top
#194203 - 2009-06-10 03:16 PM Re: IF Ingroup [Re: ares4life]
BradV Offline
Seasoned Scripter
****

Registered: 2006-08-16
Posts: 686
Loc: Maryland, USA
Well, unless there is a typo, you told the script to give access to all domain users.
 Code:
IF INGROUP("Domain Users")  
 use X: "\\bdc\adminfiles" /PERSISTENT:NO
If that is not what you meant, delete it.

For readability, I would move the function to after your scripts exit command.

Top
#194204 - 2009-06-10 03:37 PM Re: IF Ingroup [Re: BradV]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4546
Loc: USA
Comments:
1. Try to not put macros and vars in your strings
2. Paste the functions at the bottom or top of your script
3. Unless you have some old NT Stuff, there is no need for setting the time the way you are...
4. You have use X: "\\bdc\adminfiles" /PERSISTENT:NO in both ingroups... if you don't want domain users getting it, then remove this line.

Untested... and may have other things I missed, but I tried to clean your code up a little.

 Code:
;  KIXTART.SCR
;
;  KiXtart sample default logon script
;
;  Note :  This code sample is provided for demonstration purposesonly.
;          Microsoft makes no warranty, either express or implied,
;          as to its usability in any given situation.
;
;   Copyright (C) 2001 Ruud van Velsen.
;   All rights reserved.
;
CLS

small
Color b+/n
BOX (0,0,24,79,GRID)            ; 'background grid'
Color b/n
BOX (8,21,18,61,Å)              ; 'shadow' of the box'
Color g+/n
BOX (3,20,20,65,FULL)

Color w+/n
select 
  case val(left(@time,2))<12
    at (5,22) "Good Morning " + @fullname + ","
  case val(left(@time,2))<18
    at (5,22) "Good Afternoon " + @fullname + ","
  case 1
    at (5,22) "Good Evening " + @fullname + ","
endselect

at (7,22) "Please Wait For Logon script Execution"
AT ( 9,25) "Userid       : "    ; display some text strings
AT (10,25) "Full name    : "
AT (11,25) "Privilege    : "
AT (12,25) "Workstation  : "
AT (13,25) "Domain       : "
AT (14,25) "Logon Server : "

Color y+/n
AT ( 9,40) @userid              ; ...and some macro's
AT (10,40) @fullname
AT (11,40) @priv
AT (12,40) @wksta
AT (13,40) @domain
AT (14,40) @lserver

Color w/n
$userdir=@userid + "$$" ;
settime "\\PDC"

; Mount general shares for staff
;

use Z: "\\bdc\staffshares" /PERSISTENT:NO
use H: "\\bdc\" + $userdir /PERSISTENT:NO


IF INGROUP("Domain Users")  
  use X: "\\bdc\adminfiles" /PERSISTENT:NO
  If AddPrinterConnection("\\print\hp4100n") = 0
    ? AT (16,25) "Added printer connection to printer."
    $rc=SetAsDefaultPrinter("\\print\hp4100n")
  EndIf
ENDIF



; If within the Domain Admins Group
; Set the AdminFiles share

IF INGROUP("Domain Admins") 
  use X: "\\bdc\adminfiles" /PERSISTENT:NO
ENDIF

sleep 4 ;
AT (18,25) "Logon complete. Closing application"
sleep 10 ;
exit


function SetAsDefaultPrinter($printer)
  $SetAsDefaultPrinter=1
  if setdefaultprinter($printer)=0
    $SetAsDefaultPrinter=0
  else
    dim $PrintServer,$PrintQueue[0],$sharedprinter,$rc,$server
    $PrintQueue[0]="PrintQueue"
    if instr($printer,"\\") 
      $server=split($printer,"\")[2]
      $printer=split($printer,"\")[3]
    else
      $server=@wksta
    endif
    $PrintServer=GetObject("WinNT://" + $server + ",computer")
    if @error
      exit @error
    else
    $Printserver.filter=$PrintQueue   
    for each $sharedprinter in $printserver
      if $sharedprinter.name=$printer
        $rc=setdefaultprinter($sharedprinter.printername)
        if $rc=0
          $SetAsDefaultPrinter=0
          exit 0
        else
          $SetAsDefaultPrinter=$rc
          exit @error
        endif
      endif
    next
  endif 
endfunction
 


Edited by Allen (2009-06-10 03:49 PM)

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 361 anonymous users online.
Newest Members
SERoyalty, mytar, Gabriel, Alex_Evos, Dansen
17869 Registered Users

Generated in 0.051 seconds in which 0.022 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org