Page 1 of 1 1
Topic Options
#176462 - 2007-05-25 06:35 AM How to create user home drive - script
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11629
Loc: CA
FullBoost

When you say you want a script do you mean to go out and modify the data in AD or physically create the folder/share/and permissions ?

Please provide the details of what OS and what you're looking for.

Thanks.

Top
#176464 - 2007-05-25 08:47 AM Re: How to create user home drive - script [Re: NTDOC]
FullBoost Offline
Fresh Scripter

Registered: 2007-05-04
Posts: 13
Here is what I am looking for:

Server 2003
Clients: XP, win2k

During logon I want the script to check \\servername\users\ for user ID if not found create share with that UID with read/write permissions for the user and local admin with full control.

If the share is found (\\servername\users\UID$) then map drive H: to that share.

At another one of our facilities a guy set this up that no longer works there, I have been trough all the code and changed what I need to but I can’t get it to work on my script at my faculty.

On their system in the users share there is usershares of course and two other folders, 1 DELETED USERS and 2 UTILITIES I am not numbering g them that’s how they are named. Deleted users contains you guessed it deleted users, now the utilities dir is interesting inside is:
KIX32.exe
KX16.dll
KX32.dll
KX95.dll
RMTSHARE.EXE
xcacls.exe
Readme_1st.doc that contains
-------------------------------------------------
Before using UserShare.bat for the first time, you must change the default scripting engine from Wscript to Cscript. To do this, type the following at a command prompt, and then press ENTER:

cscript.exe /h:cscript
-------------------------------------------------
I did this and it was successful

usershare.bat that contains
 Code:
::
:: User Share
::
:: This script creates a shared user directory and assigns the correct 
:: Permissions
::
:: The command syntax is:    usershare {UID} {UserName}
::
:: NOTE:  Server ID is hardcoded in three lines
::        Global Administrator's Group is hardcoded in one line
::        Drive letter to the Users folder is hardcoded in one line

@echo off
if not "%2" == "" goto continue
echo.
echo.
echo        Command syntax is:    usershare  {3-4 UID}  {6-1-1 UserName}
echo.
echo.
pause
goto end

:continue
@echo on

:: Open a Mapped Drive to the USERS root folder
net use r: \\twhtshr04\users

:: Create the User's Folder
mkdir r:\%2.%1

:: Set Share Permissions on the User’s Folder
rmtshare \\twhtshr04\%1$=D:\users\%2.%1 /g %1:f

:: Set NTFS Permissions on the User’s Folder
xcacls.vbs r:\%2.%1 /g “HCA\%1:f” /I copy /Q

:: Close the Mapped Drive to the USERS root folder
net use r: /delete

pause

:end


XCACLS.vbs


Edited by FullBoost (2007-05-25 05:58 PM)

Top
#176466 - 2007-05-25 08:52 AM Re: How to create user home drive - script [Re: FullBoost]
FullBoost Offline
Fresh Scripter

Registered: 2007-05-04
Posts: 13
cleared to much info from vbs above

Edited by FullBoost (2007-05-25 05:01 PM)
Edit Reason: cleared

Top
#176467 - 2007-05-25 08:53 AM Re: How to create user home drive - script [Re: FullBoost]
FullBoost Offline
Fresh Scripter

Registered: 2007-05-04
Posts: 13
cleared to much info from vbs above

Edited by FullBoost (2007-05-25 05:01 PM)
Edit Reason: cleared

Top
#176468 - 2007-05-25 08:54 AM Re: How to create user home drive - script [Re: FullBoost]
FullBoost Offline
Fresh Scripter

Registered: 2007-05-04
Posts: 13
cleared

Edited by FullBoost (2007-05-25 05:02 PM)
Edit Reason: cleared

Top
#176469 - 2007-05-25 08:54 AM Re: How to create user home drive - script [Re: FullBoost]
FullBoost Offline
Fresh Scripter

Registered: 2007-05-04
Posts: 13
cleared

Edited by FullBoost (2007-05-25 05:02 PM)
Edit Reason: cleared

Top
#176470 - 2007-05-25 08:55 AM Re: How to create user home drive - script [Re: FullBoost]
FullBoost Offline
Fresh Scripter

Registered: 2007-05-04
Posts: 13
cleared

Edited by FullBoost (2007-05-25 05:03 PM)
Edit Reason: cleared

Top
#176471 - 2007-05-25 08:56 AM Re: How to create user home drive - script [Re: FullBoost]
FullBoost Offline
Fresh Scripter

Registered: 2007-05-04
Posts: 13
cleared

Edited by FullBoost (2007-05-25 05:03 PM)
Edit Reason: cleared

Top
#176472 - 2007-05-25 08:57 AM Re: How to create user home drive - script [Re: FullBoost]
FullBoost Offline
Fresh Scripter

Registered: 2007-05-04
Posts: 13
And on the kix side here is what I have in a drive mapping .kix called by the main kix script
 Code:
; 
; Uses GLOBAL Variables:  $PCDomain

DIM $TWHT, $CLRH, $GenShare, $UserShellFolders, $x, $IsFacServ, $Serv, $TWHT2

$TWHT             = "\\twhtshr04"
$TWHT2            = "\\twhtshr02"
$CLRH             = "\\CLRHSVR03"
$GenShare         = SUBSTR(@userid,1,9)
$UserShellFolders = "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders"



     
; ************************************************
; Home-drive mapping
   IF EXIST ("$TWHT\"+@userid+"$")
      MapDrive("H:","$TWHT\"+@userid+"$")

      IF NOT ReadValue($UserShellFolders, "Personal") = "H:\"
         $x = WriteValue($UserShellFolders, "Personal", "H:\", "REG_SZ" )
      ENDIF

      IF NOT EXIST ("H:\Favorites")
         MD "H:\Favorites"
      ENDIF
      IF NOT EXIST ("H:\Outlook")
         MD "H:\Outlook"
      ENDIF
;      IF NOT EXIST ("C:\Documents and Settings\@userid\Favorites.txt")
;         COPY "C:\Documents and Settings\@userid\Favorites\" "H:\Favorites\" /s
;      ENDIF
      IF NOT ReadValue($UserShellFolders, "Favorites") = "H:\Favorites"
         $x = WriteValue($UserShellFolders, "Favorites", "H:\Favorites", "REG_SZ" )
      ENDIF
   ENDIF



? " "

RETURN



; *************************
; *       MAPDRIVE        *
; *************************
Function MapDrive($Drive, $Path)
   Use $Drive /del
   Use $Drive $Path

   if @ERROR = 0
      ? "   Drive " + $Drive + " mapped to " + $Path
   else
      Color r+/n
      ? "   Error Mapping Drive " + $Drive + " to " + $Path + " !!"
      ? "Error: " + @Error + " - " + @SError
      Color w/n
   endif
EndFunction
RETURN


And you can see the $x up there and that is defined on my main .kix
 Code:
; *************************
; *       ISFACSERV       *
; *************************
Function IsFacServ($Serv)
   Dim $x
   $x = GetObject("LDAP://CN=" + $Serv + ", OU=s*****, OU=*****, DC=*****, DC=*****, DC=*****")
   If @Error = 0
      $IsFacServ = 1
   Else
      $IsFacServ = 0
   Endif
EndFunction
RETURN

Yes I put the ******** there \:\)

I have matched the DIR security permissions but I have been unable to replicate the security permission on the 2 utilities dir called
S-1-5-21-2142779916-377378312-1295600288-512

Ok on the server this script works on the 2 utilities DIR says access denied but I coped the DIR to get all the contents but now I can’t get it to go back to access is denied as I think that could be a reason this is not working.

If there is an easier way to do this I am all ears, I just need a way to map user home shares on the fly and connect/reconnect on logon.

Thank You


Edited by FullBoost (2007-05-25 05:59 PM)

Top
#176473 - 2007-05-25 08:58 AM Re: How to create user home drive - script [Re: FullBoost]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
Please edit your posts and put the code between [ code ] [ / code ] tags.
Top
#176480 - 2007-05-25 10:13 AM Re: How to create user home drive - script [Re: Arend_]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
 Originally Posted By: apronk
Please edit your posts and put the code between [ code ] [ / code ] tags.


And also please leave out the contents of xcacls.vbs. One should not edit anything in that code. It comes ready made from MS. I'm not going to read a script that needs 8 posts to fully show.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#176494 - 2007-05-25 03:12 PM Re: How to create user home drive - script [Re: Mart]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4567
Loc: USA
LOL. Well maybe he could squeeze all this in the shout box instead?
Top
#176496 - 2007-05-25 04:08 PM Re: How to create user home drive - script [Re: Allen]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
A mod should just delete this whole thread and start over. Stupid is what stupid does.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#176502 - 2007-05-25 05:09 PM Re: How to create user home drive - script [Re: Les]
FullBoost Offline
Fresh Scripter

Registered: 2007-05-04
Posts: 13
 Originally Posted By: Les
A mod should just delete this whole thread and start over. Stupid is what stupid does.


Ok I fixed it sorry just was not thinking when I posted that, Thanks for the constructive criticism LES.

Top
#176504 - 2007-05-25 05:25 PM Re: How to create user home drive - script [Re: FullBoost]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
[ code ] without the spaces \:\)
Top
#176507 - 2007-05-25 05:57 PM Re: How to create user home drive - script [Re: Arend_]
FullBoost Offline
Fresh Scripter

Registered: 2007-05-04
Posts: 13
Sorry I am super new to coding if you cant tell, we had a network guy who did all our logon stuff in kix and lost him so now I am just trying to make it work best I can and learn at the same time.
Top
#176511 - 2007-05-25 06:53 PM Re: How to create user home drive - script [Re: FullBoost]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11629
Loc: CA
I'll try to take a look at it further and offer advice when I have more time.

Basically though you have a security issue as I view it. You should NOT allow the system to be in a non secure state that would allow a normal user to login and create and set his/her own shares and ACL (Access Control List)
To me this is just wrong and begs for someone to come along and abuse it and or really cause problems either on purpose or accidentally. You or someone else as an Admin should be the one creating this and setting security appropriately.

Now you can write code to help you as an Admin automate it but I would never allow a user to login and create.

Top
#176516 - 2007-05-25 07:33 PM Re: How to create user home drive - script [Re: NTDOC]
FullBoost Offline
Fresh Scripter

Registered: 2007-05-04
Posts: 13
 Originally Posted By: NTDOC
I'll try to take a look at it further and offer advice when I have more time.

Basically though you have a security issue as I view it. You should NOT allow the system to be in a non secure state that would allow a normal user to login and create and set his/her own shares and ACL (Access Control List)
To me this is just wrong and begs for someone to come along and abuse it and or really cause problems either on purpose or accidentally. You or someone else as an Admin should be the one creating this and setting security appropriately.

Now you can write code to help you as an Admin automate it but I would never allow a user to login and create.


Yea it looked to me like XCACLS.vbs was creating the share with FULL user and FULL Admin rights, I would much rather prefer it to just create the share based off the domain/UID and assign R/W to the user share on their share and FULL to admin. I was looking at the other location where this script is working and I noticed a few things, there NETLOGON in based in the C:\WINNT\System32\Repl\Scripts\Import on a W2K Server box, we are Win 2003 so our NETLOGON is based in system32\GroupPolicy\Machine\Scripts so I am not sure if that is an issue as I remember scripts had to be run from the Repl Dir on win NT. Also when a user at the other location with win2k or xp logs on if kix is not found locally it installs in and at our location that does not happen so I am wondering if that might cause this to not work as well.

Thanks for your help

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
0 registered and 811 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.074 seconds in which 0.025 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