WSFTP UNC unveiled

To the Ipswitch web site

Ipswitch Forums
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      



WSFTP UNC unveiledExpand / Collapse
Author
Message
Posted 9/27/2004 5:18:22 PM


Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 9/28/2004 11:21:00 AM
Posts: 3, Visits: 1
I'm sure that I am not the only person that wanted to have my top level directory located on a UNC path. When I read that version 5 included UNC support I thought, finally a solution to my redundancy and scalability concerns. I soon found out that the UNC support in WSFTP Server would not entirely quench my UNC thirst. After a little help from the great staff at IPSwitch Support and a couple scripts later, I've got that and more!

Objectives:
1.I needed two machines setup identically for redundancy
2.Users have to be locked to their home directory
3.Those users directory’s had to be stored on a network resource
4.Users must not exist on the local machine (No AD)
a.Users must be setup on any of the FTP servers and the account must work from all the other servers once the account is created (without having to login to all the servers manually)

Here’s what I came up with. Two files that you place in the same directory on the FTP server.

Just copy the text between the **'s and paste it into your favorite text editor. Then save the file as the name given in the **'s.

There are a couple things you will need to do to these files (It's really easy)

In the first file (ftp_adduser.vbs) change the UNC path to meet your needs. This will be where your users home directories will be placed. If you don't want your users locked or want them to be able to change thier passwords just change the iftpaddu settings.

In the second file change the name of your remote servers (this will have to include the server the script is being executed from as well)

This must be done first:
Add registry subkey String Value "Remote" at HKLM\SOFTWARE\Microsoft\Windows Script Host\Settings. Set the value to "1".
You do not need to restart.


Remote_FTP_adduser.vbs is the script you run. ftp_adduser.vbs must be in the same location as Remote_FTP_adduser.vbs.



**************ftp_adduser.vbs******************
Dim sUserName, sPassWord, oWSHShell, oAddUser, sRegKey

Const cRegKey = "HKLM\Software\Ipswitch\iFtpSvc\Domains\upload.imagesilo.com\"

sUserName = WScript.Arguments(0)
sPassWord = WScript.Arguments(1)
sParameters = "C:\iftpsvc\iftpaddu +lock -chgpass -h upload.imagesilo.com -add " & sUserName & " -p " & sPassWord

Set oWSHShell = CreateObject("WScript.Shell")

'Add the User
Set oAddUser = oWSHShell.Exec(sParameters)
Do While oAddUser.Status = 0
WScript.Sleep 100
Loop

'Create the virtual directory
oWSHShell.RegWrite cRegKey & "Dirs\" & sUserName & "\_Destination", "\\(INSERT_UNC_PATH_HERE)\" & sUserName, "REG_SZ"
oWSHShell.RegWrite cRegKey & "Dirs\" & sUserName & "\_Flags", 0, "REG_DWORD"

'Set the user account to the virtual directory
oWSHShell.RegWrite cRegKey & "Users\" & sUserName & "\HomeFolder", sUserName, "REG_SZ"
***********************************************






*************Create FTP User.vbs******************
Dim oController, sRemoteScript, sUserName, sPassWord, sRemoteComputer

'Prompt for username, password and confirm the input
sUserName = InputBox("Username:","Enter Username")
sPassWord = InputBox("Password:","Enter Password")
sConfirm = MsgBox("Username: " & sUserName & vbCrLf & " Password: " & sPassWord & vbCrLf & vbCrLf & "Is this correct?", vbYesNo, "Confirm")
If sConfirm = "7" then
WScript.Quit
End if
sParameters = "ftp_adduser.vbs " & sUserName & " " & sPassWord

Set oController = WScript.CreateObject("WSHController")

'Servername must be in quotes
RemoteExecute "YOUR_REMOTE_SERVER_NAME"
RemoteExecute "SECOND_REMOTE_SERVER_NAME"

'Done
WScript.Echo "Done!" & vbCrLf & vbCrLf & "Have a Nice Day "

Function RemoteExecute(server)
Set sRemoteScript = oController.CreateScript(sParameters, server)

WScript.ConnectObject sRemoteScript, "remote_"
sRemoteScript.Execute

Do While sRemoteScript.Status <> 2
WScript.Sleep 100
Loop
WScript.DisconnectObject sRemoteScript
Set sRemoteScript = Nothing
End Function

'Error handling
Sub remote_Error
Dim theError
Set theError = sRemoteScript.Error
WScript.Echo "Error " & theError.Number & " - Line: " & theError.Line & ", Char: " & theError.Character & vbCrLf & "Description: " & theError.Description
WScript.Quit -1
End Sub
************************************************


Enjoy!

This is NOT supported AT ALL, by myself or IPSwitch. Just thought others might find it usefull...







There's got to be a harder way to do this.....
Post #1602
Posted 9/27/2004 5:23:31 PM


Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 9/28/2004 11:21:00 AM
Posts: 3, Visits: 1
Oh yeah....

You will then use a LOCAL path for your top dir. Then create a "Folder" in WSFTP Server, that points to your UNC.

All user accounts will be created in the UNC and virtual folders pointing to the UNC will also be created.....

Cheers!





There's got to be a harder way to do this.....
Post #1603
Posted 9/27/2004 5:25:22 PM


Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 9/28/2004 11:21:00 AM
Posts: 3, Visits: 1
Um.....

The smiley feature killed my old school smiley in the script.... Oh well.. *sigh*





There's got to be a harder way to do this.....
Post #1604
« Prev Topic | Next Topic »


Reading This TopicExpand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: Dave, Mark Singh, kevin r gillis, Jason Benton, Brandon Felger, Ben Henderson, Tripp Allen, Will Sansbury, Hush, FTPplanet.com, Hugh Garber, WUP-PM, mmulryan@ipswitch.com, mswimm

PermissionsExpand / Collapse

All times are GMT -5:00, Time now is 12:54pm

Powered By InstantForum.NET v4.1.4 © 2008
Execution: 0.078. 7 queries. Compression Enabled.