Java and .NET components, FTP, TELNET, SMTP, POP3, IMAP, HTTP, SSH
Home Search Knowledge Base Support

Support

Click here for access to live sales support.

For technical support please submit a ticket to the Help Desk.

 

Java and .NET Help

iPod shuffle offer

For a limited time get the newly re-designed iPod shuffle free with qualifying purchase.

Click for details.


News

Secure iNet Factory 8.0 Released
04/04/2008 02:24 PM

Updates to Email Factory for .NET and Secure iNet Factory
03/29/2008 04:06 PM

JSCAPE Secure FTP Server 3.9 Preview
03/14/2008 12:19 PM

AnyClient Service and Application Launched
03/12/2008 03:41 PM

JSCAPE Secure FTP Server 3.8 Released
02/12/2008 10:50 AM


Tutorials

Email Validation with Java
04/15/2008 02:04 PM

Sending HTML Based Email Using Java
03/11/2008 02:47 PM

Secure FTP Using Java and FTPS (FTP over SSL)
03/10/2008 04:08 PM

FTP Directory Listing Using Java
03/10/2008 03:57 PM

Sending Email Using Java
03/09/2008 03:43 PM

SSH Using Java
03/09/2008 02:53 PM


Articles

DMZ File Transfer Streaming
03/28/2008 11:57 AM

Phishing looks to FTP to distribute malware
03/13/2008 05:14 PM

Ad Hoc File Transfer Explained
03/13/2008 09:16 AM

Password Policies Made Easy
03/12/2008 03:03 PM


Feedback

Request a feature or component

Request a Java or .NET component


 

Changing Remote File Permissions - Part 2

By: Rick Stevens
April 3rd 2005

Audience: Novice

In Changing Remote File Permissions Part 1 we used the Secure FTP Factory for .NET IssueCommand() method to modify the permission settings of files on the remote Unix server.

This article expands on that concept by adding a user interface to the example code installed with Secure FTP Factory for .NET. You can download a free evaluation version of Secure FTP Factory for .NET. You can also download all the code you'll need for this article.

Important

The information in this article pertains to a Unix server only. In addition, specific permission types, such as Set group ID on execution (SGID) and "Sticky-bit" are not addressed.


In order to add a graphical permission interface we need to do two things,

  • Modify the original example interface to display the existing permissions, and
  • Add a UI form to modify the permissions of the selected files.

Modifying the example interface

Begin by opening the C# example project. By default, this project is located in the C:\Program Files\JSCAPE\Secure FTP Factory for .NET\Examples\C# directory. You can also use the Program Menu shortcut created when you installed Secure FTP Factory for .NET to open this project.

You'll notice that the example interface (FormMain.cs) contains two file list views, one for the local directory contents, and the other for the remote directory contents. We need to update the remote directory listing to display the existing file permissions. To do so, we need to modify the InitListView() method, and the references to it, and the GetRemoteListing() method to accomodate the file attributes.

The InitListView() method is responsible for initializing both the local and remote file listings. We'll need to add a flag to determine whether the file attributes column should be displayed. It is a simple matter of adding a boolean parameter and testing the condition of that paramter. If the flag is true, then we should add the column to contain the file permissions. If it is false, then the column is not added to the listing.

Add the highlighted code to the InitListView() method as shown.

protected void InitListView(ListView lvFiles, bool showPerms) {
   lvFiles.Clear();
   lvFiles.Columns.Add("Name",-2,System.Windows.Forms.HorizontalAlignment.Left);
if (showPerms) { lvFiles.Columns.Add("Attributes",-2,System.Windows.Forms.HorizontalAlignment.Left); }
}


Now we need to modify the references to the InitListView() method to pass the showPerms parameter. The example code has two references, one each in the GetLocalListing() and GetRemoteListing() methods.

Add the showPerms flag to the local listing method as shown in the following code segment.

private void GetLocalListing(string localPath) {
   // add listview headers
   InitListView(listViewLocal, false);


Add the showPerms flag to the remote listing method as shown in the following code segment.

private void GetRemoteListing(string remotePath) {
   // add listview headers
   InitListView(listViewRemote, true);


Now that we have modified the InitListView() method (and its references) we can add the code to display the permissions in the GetRemoteListing() method. Add the highlighted code to the GetRemoteListing() method as shown in the following code segment.

   int ico = 0;
string remoteFilePermissions = "";
try { if (myFtp.RemoteDir != "/") { if (textRemoteDir.Text.Length > 1) { ListViewItem lvItem = new ListViewItem("..", 0); listViewRemote.Items.Add(lvItem); } } IEnumerator remoteList = myFtp.GetDirListing(); while(remoteList.MoveNext()) { FtpFile remoteFile = (FtpFile)remoteList.Current;
remoteFilePermissions = remoteFile.Permission;
if (remoteFile.IsDirectory) { ico = 0; }else if (remoteFile.Link) { ico = 2; }else{ ico = 1; } ListViewItem lvItem = new ListViewItem(remoteFile.Filename, ico);
lvItem.SubItems.Add(remoteFilePermissions);
listViewRemote.Items.Add(lvItem); }


Testing our example

Compile the example project and press F5. You will need to specify the connection criteria specific to your Ftp server, or you can use the anonymous Ftp server provided by Netscape. The connection information is ftp.netscape.com, user = anonymous. Once the connection is established, you should see the attributes column header added to the remote file listing view.

Figure 1 shows an example result of the attributes column added to the remote listing.

Note

You will not be able to alter the contents of the Netscape server. You will need have the appropriate login credentials for your Ftp server in order to complete the next section.


Next, we'll add the code to manipulate the permission settings we want to apply to the remote directory files.

Page 1  Page 2  Page 3