Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I need a wonder script 2

Status
Not open for further replies.
Dec 24, 2003
132
0
0
US
Greetings-

Here's the deal:

After a user authenticates to Active Directory, I need a to:

Check to see if a folder is created on \\share1\%username%
If so
END

If not
Create folder \\share1\%username%
Grant %username% all permissions but Full Access
Map Drive X: for %username% to \\share1\%username%

Can we do it??? YES WE CAN!!!



Thanx
OregonSteve

"..You should never, never doubt what nobody is sure about." -Willy Wonka
 
Not a hard script to create.

You will want to grab the user name like this:

UserString = WSHNetwork.UserName

Then just use a

If Not objFSO.FolderExists("\\server\" & UserString) Then
objFSO.CreateFolder("\\server\" & UserString)
End If

You will then need to script using XCACLS to set your permissions.

I hope you find this post helpful.

Regards,

Mark
 

Popped in to learn the definition of a "Wonder Script" :)

WSHNetwork object worth a google star for Mark.
 
Hmm, so basicly you want a script that does what "Home folder" property in each users AD object does?

Why not (I assume you don't have that property set) just set that for all your users that needs this. It will automatically create a share for that user, with the correct ACL, and will automatically map the drive when the user log on. No need to take up the users time during log on with a script.

Simply copy/past \\srv\share1\%username% in to each users "Home folder" property, and choose a drive letter. If you have a lot of users, and don't want to do it manually, search these forums for a script that can change that property for all users in your domain.
 
Egil,

The HomeFolder property is really just there for legacy integration. If you had 1000 users, you would not want to copy/paste the value as you indicated. Instead I would script adding that to AD, but I would not go that way since it as I stated that is really there for legacy support.

Either way it is mute as your suggestion does not address the requested solution as using that property gives the Full Permission that Steve does not want the user to have.

I hope you find this post helpful.

Regards,

Mark
 
Hi Mark

I did'nt know that. If the HomeFolder property is just there for legacy integration, what is the recommended way of going about this nowadays then?

Ohh and by the way, your post was indeed helpful.

Regards, Egil.
 
The preferred method for configuration is to use Group Policy and scripts within the policies.

Home fodlers were pretty much eliminated by Folder Redirection in GPO. But because a lot of people like to have a drive letter, a script works best for assigning that. You can combine the script mapping with folder redirection. The folder redirection will set up all the permissions for you automatically just like the old home folder setting would, but it ia a drastically simpler support model since it is just a single setting in one GPO rather than a setting configured on each user.

I hope you find this post helpful.

Regards,

Mark
 
Ahh, so basicly I would user folder redirection to point to a UNC, and then during logon map UNC to a folder?

This way, the users that wants to use a drive letter can access their documents from the mapped drive, and those who just want to use their regular My Documents shortcut, can use that.

Regards, Egil.
 
Yes, you've got it, Egil.

I hope you find this post helpful.

Regards,

Mark
 
This is what i use in the logon to creat folders

strHomeFolder = USERNAME

If strHomeFolder <> "" Then
If Not WSHFSO.FolderExists(strHomeFolder) Then
On Error Resume Next
WSHFSO.CreateFolder "\\server\employee folders\" & strHomeFolder
If Err.Number <> 0 Then
On Error GoTo 0

End If
On Error GoTo 0
End If
End if
strNetBIOSDomain = "server.net"

If WSHFSO.FolderExists(strHomeFolder) Then
' Assign user permission to home folder.
intRunError = WSHShell.Run("%COMSPEC% /c Echo Y| cacls " _
& strHomeFolder & " /T /E /C /G " & strNetBIOSDomain _
& "\" & USERNAME & ":F", 2, True)
wscript.echo intRunError
If intRunError <> 0 Then
Wscript.Echo "Error assigning permissions for user " _
& USERNAME & " to home folder " & strHomeFolder
End If
End If
Sub MapDrive(sDrive,sShare,sHome)
On Error Resume Next
WSHNetwork.RemoveNetworkDrive sDrive
Err.Clear
WSHNetwork.MapNetworkDrive sDrive,sShare
MSIE.Document.Write "<BR>Mapping " & sDrive & " to " & sShare

If sHome = 1 Then
HOME = sDrive
End If
if Err.Number <> 0 Then
MSIE.Document.Write "<BR><FONT COLOR=#FF6666>ERROR! Mapping network drive " & sDrive & " Reason: " & Err.Description & "</FONT>"
NErr = 1
End if

End Sub

I dont know that much about scripts but this has always worked for me so either I got lucky or I got really luck

hope this is usefull

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top