473,380 Members | 1,362 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,380 software developers and data experts.

Multiple File copy to Web Server

Long time reader, first time poster... Any help is appreciated.

I have a few questions regarding Winform controls embedded within an
html page. For more info please see the appendix. Now, for the

1. A button on my control executes the
System.IO.Directory.GetDirectories funtion (the scanned directory
resides on the hosting web server). What credentials is this
accomplished with from the client machine, the users windows login or
a .NET machine account? Can these credentials be changed (kind of like
an impersonate in ASP.NET)?

2. I have a button on my control that executes the System.IO.File.Copy
method (again the "copy to" directory resides on the hosting web
server). Same questions as above regarding credentials...

3. Ideally I would like to authentice the user and then execute the
remainder of the controls file functions under the identity of a
specific AD account (one such that the users do not even know exits).
Is this possible?

Please keep in mind this all executes on the client machine and does
not utilize ASP.Net.

The Original Problem:
1. Copy multiple html, htm, css, jpg, jpeg, gif, etc,.. files from a
client machine to two web servers (they are load balanced) within our
company intranet.
2. Use AD for authentication purposes.

1. Provide a browser based solution (these people want WEB, WEB, WEB).
2. Scan the "Dept" folder on one of the hosting web servers. Extract
the names of all department folders within the "Dept" folder to aid in
authentication purposes. This is accomplished by appending the string
"_Pubs" to the end of each department name (thus creating the AD OU)
and using "myPrincipal.IsInRole("domainname<i>\" + Dept + "_Pubs")
3. For users that log into the domain, authenticate against their AD
OU (<i>deptname_Pubs).
4. For users that do not log into the domain, prompt for credentials
then authenticate against their AD OU (deptname_Pubs).

My Solution:
Use a Windows Form Control within an html page. Utilize the System.IO
class for all file scan and copy functions. Utilize the
System.Security.Principal class for active directory authentication.
Note: This solution works perfectly for me because I am an
administrator on the web servers. My users will not be.

Below is the relevant code for anyone interested. Some of the names
and code have been changed to protect the innocent:

The Code
'************************************************* ************************
Public Class ctlWCL
Inherits System.Windows.Forms.UserControl
Dim sServerPath As String = "\\DefaultServer\Shared\"
Dim saFiles(), sSourceFolder, sDestFolder, sSurveyURL As String
Dim objActivePub As Publisher

Private Sub lnkSurvey_LinkClicked(ByVal ...) Handles
'This function provides the url to the user
Dim process As New System.Diagnostics.Process
process.StartInfo.FileName = "iexplore"
process.StartInfo.Arguments = lnkSurvey.Text
End Sub

Private Sub cmdPublish_Click(ByVal ...) Handles cmdPublish.Click
Dim sFullFileName, sFileName, sSurveyName, sTXTName,
sDestDirectoryOne, sDestDirectoryTwo As String
Dim i, j As Integer
Me.Cursor = Cursors.WaitCursor
'Get full File Name
sTXTName = cmbSurveys.Items(cmbSurveys.SelectedIndex).ToStrin g

'Determine the Survey Name
sSurveyName = sTXTName.ToUpper.Substring(0, Len(sTXTName) -

'Build the Destination Directories
If optDevProduction.Checked Then
sDestDirectoryOne = "\\Server5\Docs\" + objActivePub.Dept + "\"
sDestDirectoryTwo = "\\Server6\Docs\" + objActivePub.Dept + "\"
sSurveyURL = "http://PrdURL/Dept/"
ElseIf optStaging.Checked Then
sDestDirectoryOne = "\\Server3\Docs\" + objActivePub.Dept + "\"
sDestDirectoryTwo = "\\Server4\Docs\" + objActivePub.Dept + "\"
sSurveyURL = "http://StgURL/Dept/"
sDestDirectoryOne = "\\Server1\Docs\" + objActivePub.Dept + "\"
sDestDirectoryTwo = "\\Server2\Docs\" + objActivePub.Dept + "\"
sSurveyURL = "http://DevURL/Dept/"
End If

'Copy all survey htm, html, css, jpg, gif, pdc files
For i = 0 To saFiles.GetUpperBound(0)

sFullFileName = saFiles(i).ToUpper
'Allow all files with surveyname and extentions of (HTM or HTML or
'Or all files with .CSS, .JPG, .GIF etc...
If (sFullFileName.IndexOf(sSurveyName) > -1 And
(sFullFileName.IndexOf(".HTM") > -1 Or sFullFileName.IndexOf(".TXT") >
-1 Or sFullFileName.IndexOf(".HTML") > -1)) _"
Or sFullFileName.IndexOf(".GIF") > -1 Or _
sFullFileName.IndexOf(".JPG") > -1 Or _
sFullFileName.IndexOf(".JPEG") > -1 Or _
sFullFileName.IndexOf(".JFF") > -1 Or _
sFullFileName.IndexOf(".JTF") > -1 Or _
sFullFileName.IndexOf(".PNG") > -1 Or _
sFullFileName.IndexOf(".BMP") > -1 Or _
sFullFileName.IndexOf(".TIF") > -1 Or _
sFullFileName.IndexOf(".TIFF") > -1 Or _
sFullFileName.IndexOf(".WMF") > -1 Or _
sFullFileName.IndexOf(".RAS") > -1 Or _
sFullFileName.IndexOf(".EPS") > -1 Or _
sFullFileName.IndexOf(".PCX") > -1 Or _
sFullFileName.IndexOf(".PCD") > -1 Or _
sFullFileName.IndexOf(".TGA") > -1 Or _
sFullFileName.IndexOf(".CSS") > -1 Or _
sFullFileName.IndexOf(".JS") > -1 Then
sFileName = System.IO.Path.GetFileName(sFullFileName)
System.IO.File.Copy(saFiles(i), sDestDirectoryOne + sFileName, True)
System.IO.File.Copy(saFiles(i), sDestDirectoryTwo + sFileName, True)
End If
lblWorking.Text = "Publishing Complete, Please Bookmark The Survey URL
lnkSurvey.Visible = True
lnkSurvey.Text = sSurveyURL + objActivePub.Dept + "/" + sSurveyName +
Me.Cursor = Cursors.Default
Catch ex As Exception
End Try
End Sub

Private Sub cmdBrowse_Click(ByVal ...) Handles cmdBrowse.Click
'This function will allow the user to select the copy from directory
Dim i As Integer
Dim sFileName As String
Dim di As New System.Windows.Forms.FolderBrowserDialog
sSourceFolder = di.SelectedPath.ToString()
If sSourceFolder.Length > 0 Then
lblPath.Text = sSourceFolder
saFiles = System.IO.Directory.GetFiles(sSourceFolder)
For i = 0 To saFiles.GetUpperBound(0)
If saFiles(i).ToUpper.IndexOf(".PDC") > 0 Then
sFileName = System.IO.Path.GetFileName(saFiles(i))
End If
End If
Catch ex As Exception
End Try
End Sub

Private Function AuthorizedPublisher() As Boolean
'This Function Authenticates the User
Dim myPrincipal As New
System.Security.Principal.WindowsPrincipal(System. Security.Principal.WindowsIdentity.GetCurrent)
Dim i As Integer = 1
Dim Dept As String

Dim Departments() As String =
For i = 0 To Departments.GetUpperBound(0)
Dept = Departments(i).Remove(0, Len(sServerPath))
If myPrincipal.IsInRole("domainname\" + Dept + "_Pubs") Then
objActivePub = New Publisher(Dept)
objActivePub.User = myPrincipal.Identity.Name.ToString
Return True
End If
lblError.Text = "Unable To Authorize User!!!"
Return False
Catch ex As Exception
End Try
End Function
End Class
Jul 21 '05 #1
0 2546

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: caro | last post by:
Hi I am trying to write two Select * statements to the same text file using bcp (from a stored procedure). But cannot find a way of appending to a file using bcp. Does anyone know if this...
by: Tim Mulholland | last post by:
My company is about to begin working on an ASP.NET application. There are going to be two primary developers working on this project. It will be a fairly deep project (lots of lines of code) but...
by: jsale | last post by:
I have made an ASP.NET web application that connects to SQL Server, reading and writing data using classes. I was recommended to use session objects to store the data per user, because each user...
by: Tess | last post by:
Hi, Long time reader, first time poster... Any help is appreciated. I have a few questions regarding Winform controls embedded within an html page. For more info please see the appendix. Now,...
by: Matt D | last post by:
I've got two web services that use the same data types and that clients will have to consume. I read the msdn article on sharing types...
by: Olie | last post by:
This post is realy to get some opinions on the best way of getting fast comunication between multiple applications. I have scowered the web for imformation on this subject and have just found...
by: ghart | last post by:
Hello all, I have been trying to determine the best way to do this, but can't seem to get any solution to work exactly the way I want. The scenario is that I have some xml files being placed on...
by: Tim | last post by:
Hi Folks, I'm used to a UNLOAD command that allows me to dump to a named flat file the results of any SELECT statement. Hence one can build a single SQL file which contains multiple SQL...
by: johngault | last post by:
I've been working with this PHP page for several days now and I'm stumped. The page is supposed to allow the user to upload up to six images for their profile. When the user adds an image it (the...
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.