How to disable DELETE from the CONTEXT MENU while using FTP Management

4 posts, 0 answers
  1. Ajay
    Ajay avatar
    66 posts
    Member since:
    May 2009

    Posted 10 Dec 2009 Link to this post

    Hi Telerik guys !

    I have two ROOTS within my RADFILE EXPLORER.

    For example :-
            + ----- FTP 

            + ----- ROOT


    Iam getting the DELETE option for FTP(I can delete the folder/file within the FTP)

    What Iam here is loking for is NOT TO SHOW the DELETE option for ROOT. 

    Below is the code Iam have written for this :--

     protected void Page_Load(object sender, EventArgs e)  
        {  
            try 
            {  
                MessageLabel.Text = "";  
                SuccessImage.Visible = false;  
     
     
     
                if (Session["UserID"] == null)  
                {  
                    Session.Clear();  
                    Response.Redirect("~/ExpiredMessage.aspx");  
                }  
     
                RadScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "PopForReport""function newWindow(url) { var popupWindow = window.open(url,'popUpWindow','height=700,width=600,left=100,top=100,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no, location=no,directories=no, status=yes'); return false; }"true);  
                RadScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "ErrorHandler""function handlerFunction(description,page,line) {return true;} window.onerror = handlerFunction;"true);  
                RadScriptManager.RegisterClientScriptInclude(Page, Page.GetType(),"pasword_encrypt""script/encode.js");  
                 
     
            }  
            catch (Exception ex)  
            {  
                //throw new Exception(ex.Message.ToString());  
                StackTrace stackError = new StackTrace(new StackFrame(true));  
                BLLError.SetErrorProperties(ex.Message, stackError, short.Parse(Session["UserID"].ToString()));  
            }  
     
     
            GetMappedPath GMP = new GetMappedPath();  
     
            Dictionary<stringstring> mappedPathsInConfigFile = GMP.GetMappingsFromConfigFile();  
            //string DocumentPath = "";  
            string[] DocumentPath = new string[2];  
            int index = 0;  
            foreach (KeyValuePair<stringstring> mappedPath in mappedPathsInConfigFile)  
            {  
                DocumentPath[index] = mappedPath.Value.Replace("/""\\");  
                index += 1;  
            }  
     
            string[] viewPaths = new string[] { DocumentPath[1], DocumentPath[0]};  
            //string[] uploadPaths = new string[] { DocumentPath[1], DocumentPath[0]};  
            string[] deletePaths = new string[] { DocumentPath[1] };  
     
     
     
            FTPManagementRadFileExplorer.Configuration.ContentProviderTypeName = typeof(FTPCustomFileSystemProvider).AssemblyQualifiedName;  
            FTPManagementRadFileExplorer.Configuration.ViewPaths = viewPaths;  
            FTPManagementRadFileExplorer.Configuration.DeletePaths = deletePaths;  
              
        }  
     

    As from the above code :-

    viewPaths ----> is for Both the FTP  &  Root

    While,  deletePaths -----> is for FTP  only.


    But when I run my application Iam not able to see the DELETE option removed from my ROOT option.

    I dont know why is this so ??


    Below is the SCREEN SHOT for this .


    Please help ?

    Ajay
  2. Fiko
    Admin
    Fiko avatar
    1406 posts

    Posted 15 Dec 2009 Link to this post

    Hello Ajay,

     In order to help I need to examine the values stored in the DocumentPath[1] and DocumentPath[0] variables. Could you please paste the values here and I will do my best to help. Also, please paste the function that checks the delete permissions. For example, in the implemented FtpContentProvider in this KB we used the HasDeletePermissions that returns whether a path has delete permission or not.

    I am looking forward to hearing from you.

    Kind regards,
    Fiko
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Ajay
    Ajay avatar
    66 posts
    Member since:
    May 2009

    Posted 16 Dec 2009 Link to this post

    Hi Fiko !

    I have attached the four screen shots , out of which two SCREEN SHOT lets you what values Iam getting within my DocumentPath[0] & DocumentPath[1].

    While, two other SCREEN-SHOTS lets you to show what values Iam getting within my

    viewPath  & what in deletePath

    Please acknowledge the attachments.

    Apart from that I have pasted the function that checks the delete permission within the FTPCustomFileSystemProvider.cs class.

     public override bool CheckDeletePermissions(string virtualTargetPath)  
        {  
            string physicalTargetPath = this.GetPhysicalFromVirtualPath(virtualTargetPath);  
            if (physicalTargetPath == null)  
                return false;  
     
            // The upload permission is no set ==> no write permission;  
            // Also check whether the write permission is set in the fileSystem   
            return HasDeletePermission(physicalTargetPath) && FileSystem.CheckWritePermission(physicalTargetPath, virtualTargetPath);  
        } 

    also,

     private bool HasDeletePermission(string physicalPath)  
        {  
     
            foreach (string deletePath in this.DeletePaths)  
            {  
                if (GMP.AddSlashAtEndOfPhysicalPath(physicalPath).StartsWith(GMP.AddSlashAtEndOfPhysicalPath(deletePath), StringComparison.CurrentCultureIgnoreCase))  
                {  
                    // Else ;  
                    return true;  
                }  
            }  
            return false;  

    Please help how to proceed ?

    Wating for your fastest reply.

    Ajay

  5. Fiko
    Admin
    Fiko avatar
    1406 posts

    Posted 18 Dec 2009 Link to this post

    Hello Ajay,

    I am little bit confused with your code. In your first post I saw that you name the provider FTPCustomFileSystemProvider and I assumed that you use this code library as a base in your project. In the screenshots, however, I see that you use physical paths. Please note that since you use your own content provider (maybe based only on this KB article) and I need to take a closer look over your code in order to provide a solution of the problem.
    Could you please open a new support ticket and send me a project that reproduces the problem? I will check it and do my best to provide a solutions as soon as possible.


    Sincerely yours,
    Fiko
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top