Page 1 of 1 1
Topic Options
#6628 - 2001-02-01 09:47 AM Exporting Permissions on Shares
Anonymous
Unregistered


Hello,

I dont know whether you can do this via script or if there is a utility out there that will do it for me...

Basically Im doing some major changes on my NT4 Server disk array and I want to backup my shares and the permissions on each share. The idea I had in mind was to export them out to a text file but Im open to any suggestions.

I could simply write the permissions out by hand but that would take ages.

Any suggestions would be appreciated.

Thanks,

Terry.

Top
#6629 - 2001-02-01 10:46 AM Re: Exporting Permissions on Shares
Anonymous
Unregistered


Hello Terry..,

I am working on it and will post a script to day..!!

Oeps Sorry..!! Didn't got really to it to complete it.. but I will complete it to morrow.. Sorry
------------------
To Be Of Service..,
Fabian.
-----------------Paranoia is reality on a finer scale-----------------

[This message has been edited by Fabian (edited 01 February 2001).]

Top
#6630 - 2001-02-03 12:04 AM Re: Exporting Permissions on Shares
Anonymous
Unregistered


Hello Terry..,

Finally I had the time to finish it.

code:
 ;	Kix32 script ReCrEaTsHaReS.kix
; Created February 02, 2001 by Fabian Strubel
; Updated February 02, 2001 by Fabian Strubel
; Version 1.00

; Start of script

:Start
CLS
BREAK ON
MD "@CURDIR\Temp"
MD "@CURDIR\Output"
GOTO CreateCMD

; Greate Windows/NT command interpreter ReCrEaTsHaReS.cmd

:CreateCMD
$GarBage="The command c,Share name,-------------"
$Excludes="A$,ADMIN$,B$,C$,D$,E$,F$,G$,H$,I$,IPC$,J$,K$,L$,M$,N$,NETLOGON,O$,P$,Q$,R$,S$,T$,U$,V$,W$,X$,Y$,Z$"
AT(02,02)"Greate Input files with share info per system"
DEL "@CURDIR\Temp\*.*"
$NULL=OPEN(1,"@CURDIR\Input\ScanSystems.inp")
$LINE1=READLINE(1)
WHILE @ERROR=0
$WKSTA=RTRIM(LCASE($LINE1))
AT(04,02)"Scanning System : "$WKSTA
SHELL'CMD /X/C "@CURDIR\Bin\Rmtshare.exe \\$WKSTA>@CURDIR\Temp\RmtshareOutPut.tmp"'
$NULL=OPEN(2,"@CURDIR\Temp\RmtshareOutPut.tmp")
DEL "@CURDIR\OutPut\ReCrEaTsHaReS.cmd"
$NULL=OPEN(3,"@CURDIR\OutPut\ReCrEaTsHaReS.cmd",5)
$LINE2=READLINE(2)
WHILE @ERROR=0
$Share=RTRIM(SUBSTR($LINE2,1,13))
IF INSTR($GarBage,$Share)=0 AND INSTR($Excludes,$Share)=0
AT(05,02)"Shares found : "$Share
SHELL'CMD /X/C "@CURDIR\Bin\Rmtshare.exe \\$WKSTA\"$Share">@CURDIR\Temp\"$WKSTA"_"$Share"_OutPut.tmp"'
$NULL=OPEN(4,"@CURDIR\Temp\"+$WKSTA+"_"+$Share+"_OutPut.tmp")
$LINE4=READLINE(4)
WHILE @ERROR=0
SELECT
CASE RTRIM(SUBSTR($LINE4,1,14))="Share name"
$ShareName=LTRIM(SUBSTR($LINE4,14,LEN($LINE4)-13))
CASE RTRIM(SUBSTR($LINE4,1,14))="Path"
$Path=LTRIM(SUBSTR($LINE4,14,LEN($LINE4)-13))
CASE RTRIM(SUBSTR($LINE4,1,14))="Remark"
IF LTRIM(SUBSTR($LINE4,14,LEN($LINE4)-13))=""
$CMD_Remark=" /REMARK:"+CHR(34)+"No Remarks"+CHR(34)+""
ELSE
$CMD_Remark=" /REMARK:"+CHR(34)+LTRIM(SUBSTR($LINE4,14,LEN($LINE4)-13))+CHR(34)+""
ENDIF
CASE RTRIM(SUBSTR($LINE4,1,14))="Maximum users"
IF LTRIM(SUBSTR($LINE4,14,LEN($LINE4)-13))="No limit"
$CMD_MaximumUsers=" /UNLIMITED"
ELSE
$CMD_MaximumUsers=" /USERS:"+LTRIM(SUBSTR($LINE4,14,LEN($LINE4)-13))
ENDIF
CASE RTRIM(SUBSTR($LINE4,1,14))="Permissions:"
$Permissions=LTRIM(SUBSTR($LINE4,14,LEN($LINE4)-13))
$CMD_Permissions=""
$LINE4=READLINE(4)
WHILE LTRIM($LINE4)<>"The command completed successfully."
IF INSTR($LINE4,"NT AUTHORITY\")<>0
$LINE4=SUBSTR($LINE4,14,LEN($LINE4)-13)
ENDIF
IF INSTR($LINE4," BUILTIN\")<>0
$LINE4=SUBSTR($LINE4,10,LEN($LINE4)-9)
ENDIF
IF INSTR($LINE4,"\Everyone")<>0
$LINE4=SUBSTR($LINE4,10,LEN($LINE4)-9)
ENDIF
IF INSTR($LINE4,": NONE")<>0
$CMD_Permissions=" /GRANT "+CHR(34)+RTRIM(LTRIM(SUBSTR($LINE4,1,LEN($LINE4)-7)))+CHR(34)+":N"+$CMD_Permissions
ENDIF
IF INSTR($LINE4,": READ")<>0
$CMD_Permissions=" /GRANT "+CHR(34)+RTRIM(LTRIM(SUBSTR($LINE4,1,LEN($LINE4)-7)))+CHR(34)+":R"+$CMD_Permissions
ENDIF
IF INSTR($LINE4,": CHANGE")<>0
$CMD_Permissions=" /GRANT "+CHR(34)+RTRIM(LTRIM(SUBSTR($LINE4,1,LEN($LINE4)-9)))+CHR(34)+":C"+$CMD_Permissions
ENDIF
IF INSTR($LINE4,": FULL CONTROL")<>0
$CMD_Permissions=" /GRANT "+CHR(34)+RTRIM(LTRIM(SUBSTR($LINE4,1,LEN($LINE4)-15)))+CHR(34)+":F"+$CMD_Permissions
ENDIF
$LINE4=READLINE(4)
LOOP
ENDSELECT
$LINE4=READLINE(4)
LOOP
$NULL=CLOSE(4)
$CMD_Share=$ShareName+"="+$Path
$NULL=WRITELINE(3,"RMTSHARE "+$CMD_Share+$CMD_Remark+$CMD_MaximumUsers+$CMD_Permissions+CHR(13)+CHR(10))
ENDIF
$LINE2=READLINE(2)
LOOP
$NULL=CLOSE(3)
$NULL=CLOSE(2)
$LINE1=READLINE(1)
LOOP
GOTO End

; End of Script

:End
EXIT


What you need: Rmtshare.exe (linker version 5.12) in the dir '@CURDIR\Bin' and an input file 'ScanSystems.inp' in the dir '@CURDIR\Input'.

What to do: Enter in the input file 'ScanSystems.inp' the bare NETBios names of the systems you want to create the CMD script for.

What can it do: It creates a Windows/NT command interpreter script for all non-default shares, but you should excluse the printershares..

I hope this is something you where looking for.

------------------
To Be Of Service..,
Fabian.
-----------------Paranoia is reality on a finer scale-----------------

Top
#6631 - 2001-02-06 09:25 AM Re: Exporting Permissions on Shares
Anonymous
Unregistered


WOW!
This is a great script Fabian. So much more than what I expected. Kixtart continues to amaze me the sorts of things it can do, especially utilising other command line utilities.

I think I will use this script to periodically backup all the shares and their details on a on all our Servers.

Thanks heaps.

Terry.

Top
#6632 - 2001-02-06 10:01 AM Re: Exporting Permissions on Shares
Anonymous
Unregistered


Hya Terry..,

Well thank you for the posting the question.., I gave me some idea's to work with..!!
I am still owrking on a script which recreats the printershares and driver setting..!! I you are interested.., just post or send an email..

Cya..!!

[This message has been edited by Fabian (edited 06 February 2001).]

Top
#6633 - 2001-02-07 08:54 AM Re: Exporting Permissions on Shares
Anonymous
Unregistered


Fabian,

I made a small change (I hope you dont mind). When checking the share in the RmtshareOutPut.tmp file, you had a limitation of 13 character for the share name. The rest of the share would be truncated. I have replaced the line of code:
$Share=RTRIM(SUBSTR($LINE2,1,13))
to:
$Share=RTRIM(SUBSTR($LINE2,1,INSTR($LINE2,":\")-2))

I have run it and it seems to work fine. If I find any more "bits" I will let you know.

Terry.

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 957 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.055 seconds in which 0.027 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