예제 #1
0
        public WebDavFolderRule[] GetFolderWebDavRules(string organizationId, string folder, WebDavSetting setting)
        {
            var webDavSetting = GetWebDavSetting(setting);

            IWebDav webdav = new WebDav(webDavSetting);

            return(webdav.GetFolderWebDavRules(organizationId, folder));
        }
예제 #2
0
        public bool SetFolderWebDavRules(string organizationId, string folder, WebDavSetting setting,
                                         WebDavFolderRule[] rules)
        {
            var users = new List <UserPermission>();

            foreach (var rule in rules)
            {
                foreach (var user in rule.Users)
                {
                    users.Add(new UserPermission
                    {
                        AccountName = user,
                        Read        = rule.Read,
                        Write       = rule.Write
                    });
                }

                foreach (var role in rule.Roles)
                {
                    users.Add(new UserPermission
                    {
                        AccountName = role,
                        Read        = rule.Read,
                        Write       = rule.Write
                    });
                }
            }

            var webDavSetting = GetWebDavSetting(setting);

            string path = string.Format("{0}:\\{1}\\{2}\\{3}", webDavSetting.LocationDrive, webDavSetting.HomeFolder,
                                        organizationId, folder);

            SecurityUtils.ResetNtfsPermissions(path);

            // 06.09.2015 [email protected]
            // Problem: Serversettings for the Method 'GrantGroupNtfsPermission' is an Default Object, but we need the real Object
            // for the real Settings, to determine Objects from AD
            // Fix: Give the Helper-Class SecurityUtils the real ServerSettings-Object
            // SecurityUtils.GrantGroupNtfsPermissions(path, users.ToArray(), false, new RemoteServerSettings(), null, null);
            SecurityUtils.GrantGroupNtfsPermissions(path, users.ToArray(), false, ServerSettings, "*", "*");

            IWebDav webdav = new WebDav(webDavSetting);

            return(webdav.SetFolderWebDavRules(organizationId, folder, rules));
        }
예제 #3
0
        public SystemFile RenameFolder(string organizationId, string originalFolder, string newFolder, WebDavSetting setting)
        {
            var webDavSetting = GetWebDavSetting(setting);

            var oldPath = string.Format("{0}:\\{1}\\{2}\\{3}", webDavSetting.LocationDrive, webDavSetting.HomeFolder,
                                        organizationId, originalFolder);
            var newPath = string.Format("{0}:\\{1}\\{2}\\{3}", webDavSetting.LocationDrive, webDavSetting.HomeFolder,
                                        organizationId, newFolder);

            FileUtils.MoveFile(oldPath, newPath);

            IWebDav webdav = new WebDav(webDavSetting);

            //deleting old folder rules
            webdav.DeleteAllWebDavRules(organizationId, originalFolder);

            return(GetFolder(organizationId, newFolder, webDavSetting));
        }
예제 #4
0
        public bool SetFolderWebDavRules(string organizationId, string folder, WebDavSetting setting,
                                         WebDavFolderRule[] rules)
        {
            var users = new List <UserPermission>();

            foreach (var rule in rules)
            {
                foreach (var user in rule.Users)
                {
                    users.Add(new UserPermission
                    {
                        AccountName = user,
                        Read        = rule.Read,
                        Write       = rule.Write
                    });
                }

                foreach (var role in rule.Roles)
                {
                    users.Add(new UserPermission
                    {
                        AccountName = role,
                        Read        = rule.Read,
                        Write       = rule.Write
                    });
                }
            }

            var webDavSetting = GetWebDavSetting(setting);

            string path = string.Format("{0}:\\{1}\\{2}\\{3}", webDavSetting.LocationDrive, webDavSetting.HomeFolder,
                                        organizationId, folder);

            SecurityUtils.ResetNtfsPermissions(path);
            SecurityUtils.GrantGroupNtfsPermissions(path, users.ToArray(), false, new RemoteServerSettings(), null, null);
            //SecurityUtils.GrantGroupNtfsPermissions(path, users.ToArray(), false, ServerSettings, "*", "*");

            IWebDav webdav = new WebDav(webDavSetting);

            return(webdav.SetFolderWebDavRules(organizationId, folder, rules));
        }
예제 #5
0
        public void DeleteFolder(string organizationId, string folder, WebDavSetting setting)
        {
            var webDavSetting = GetWebDavSetting(setting);

            string rootPath = string.Format("{0}:\\{1}\\{2}\\{3}", webDavSetting.LocationDrive, webDavSetting.HomeFolder,
                                            organizationId, folder);

            DirectoryInfo treeRoot = new DirectoryInfo(rootPath);

            if (treeRoot.Exists)
            {
                DirectoryInfo[] dirs = treeRoot.GetDirectories();
                while (dirs.Length > 0)
                {
                    foreach (DirectoryInfo dir in dirs)
                    {
                        DeleteFolder(organizationId,
                                     folder != string.Empty ? string.Format("{0}\\{1}", folder, dir.Name) : dir.Name,
                                     webDavSetting);
                    }

                    dirs = treeRoot.GetDirectories();
                }

                // DELETE THE FILES UNDER THE CURRENT ROOT
                string[] files = Directory.GetFiles(treeRoot.FullName);
                foreach (string file in files)
                {
                    File.SetAttributes(file, FileAttributes.Normal);
                    File.Delete(file);
                }

                IWebDav webdav = new WebDav(webDavSetting);

                webdav.DeleteAllWebDavRules(organizationId, folder);

                Directory.Delete(treeRoot.FullName, true);
            }
        }
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     this.label1          = new System.Windows.Forms.Label();
     this.edtHost         = new System.Windows.Forms.TextBox();
     this.label2          = new System.Windows.Forms.Label();
     this.edtUser         = new System.Windows.Forms.TextBox();
     this.label3          = new System.Windows.Forms.Label();
     this.edtPassword     = new System.Windows.Forms.TextBox();
     this.label4          = new System.Windows.Forms.Label();
     this.cbDepth         = new System.Windows.Forms.ComboBox();
     this.label5          = new System.Windows.Forms.Label();
     this.lvResources     = new System.Windows.Forms.ListView();
     this.columnHeader1   = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
     this.btnOpen         = new System.Windows.Forms.Button();
     this.btnGoUp         = new System.Windows.Forms.Button();
     this.btnCapabilities = new System.Windows.Forms.Button();
     this.btnGetAllProps  = new System.Windows.Forms.Button();
     this.btnModifyProp   = new System.Windows.Forms.Button();
     this.btnMakeDir      = new System.Windows.Forms.Button();
     this.btnDelete       = new System.Windows.Forms.Button();
     this.btnLock         = new System.Windows.Forms.Button();
     this.btnUnlock       = new System.Windows.Forms.Button();
     this.btnCopyMove     = new System.Windows.Forms.Button();
     this.btnDownload     = new System.Windows.Forms.Button();
     this.btnUpload       = new System.Windows.Forms.Button();
     this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
     this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();
     this.webDav1         = new CleverComponents.InetSuite.WebDav();
     this.SuspendLayout();
     //
     // label1
     //
     this.label1.Location = new System.Drawing.Point(16, 19);
     this.label1.Name     = "label1";
     this.label1.Size     = new System.Drawing.Size(32, 16);
     this.label1.TabIndex = 0;
     this.label1.Text     = "Host";
     //
     // edtHost
     //
     this.edtHost.Location = new System.Drawing.Point(64, 16);
     this.edtHost.Name     = "edtHost";
     this.edtHost.Size     = new System.Drawing.Size(328, 20);
     this.edtHost.TabIndex = 1;
     this.edtHost.Text     = "http://localhost/WebDAV/";
     //
     // label2
     //
     this.label2.Location = new System.Drawing.Point(16, 51);
     this.label2.Name     = "label2";
     this.label2.Size     = new System.Drawing.Size(40, 16);
     this.label2.TabIndex = 2;
     this.label2.Text     = "User";
     //
     // edtUser
     //
     this.edtUser.Location = new System.Drawing.Point(64, 48);
     this.edtUser.Name     = "edtUser";
     this.edtUser.Size     = new System.Drawing.Size(112, 20);
     this.edtUser.TabIndex = 3;
     //
     // label3
     //
     this.label3.Location = new System.Drawing.Point(208, 51);
     this.label3.Name     = "label3";
     this.label3.Size     = new System.Drawing.Size(64, 16);
     this.label3.TabIndex = 4;
     this.label3.Text     = "Password";
     //
     // edtPassword
     //
     this.edtPassword.Location     = new System.Drawing.Point(272, 48);
     this.edtPassword.Name         = "edtPassword";
     this.edtPassword.PasswordChar = '*';
     this.edtPassword.Size         = new System.Drawing.Size(120, 20);
     this.edtPassword.TabIndex     = 5;
     //
     // label4
     //
     this.label4.Location = new System.Drawing.Point(16, 83);
     this.label4.Name     = "label4";
     this.label4.Size     = new System.Drawing.Size(40, 16);
     this.label4.TabIndex = 6;
     this.label4.Text     = "Depth";
     //
     // cbDepth
     //
     this.cbDepth.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
     this.cbDepth.Items.AddRange(new object[] {
         "Default",
         "Resource Only",
         "Resource and Children",
         "Infinity"
     });
     this.cbDepth.Location = new System.Drawing.Point(64, 80);
     this.cbDepth.Name     = "cbDepth";
     this.cbDepth.Size     = new System.Drawing.Size(112, 21);
     this.cbDepth.TabIndex = 7;
     //
     // label5
     //
     this.label5.Location = new System.Drawing.Point(16, 118);
     this.label5.Name     = "label5";
     this.label5.Size     = new System.Drawing.Size(64, 15);
     this.label5.TabIndex = 8;
     this.label5.Text     = "Resources";
     //
     // lvResources
     //
     this.lvResources.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
         this.columnHeader1
     });
     this.lvResources.FullRowSelect = true;
     this.lvResources.HideSelection = false;
     this.lvResources.Location      = new System.Drawing.Point(16, 136);
     this.lvResources.Name          = "lvResources";
     this.lvResources.Size          = new System.Drawing.Size(376, 264);
     this.lvResources.TabIndex      = 9;
     this.lvResources.UseCompatibleStateImageBehavior = false;
     this.lvResources.View         = System.Windows.Forms.View.Details;
     this.lvResources.DoubleClick += new System.EventHandler(this.lvResources_DoubleClick);
     //
     // columnHeader1
     //
     this.columnHeader1.Text  = "Path";
     this.columnHeader1.Width = 350;
     //
     // btnOpen
     //
     this.btnOpen.Location = new System.Drawing.Point(408, 16);
     this.btnOpen.Name     = "btnOpen";
     this.btnOpen.Size     = new System.Drawing.Size(88, 23);
     this.btnOpen.TabIndex = 10;
     this.btnOpen.Text     = "Open";
     this.btnOpen.Click   += new System.EventHandler(this.btnOpen_Click);
     //
     // btnGoUp
     //
     this.btnGoUp.Location = new System.Drawing.Point(408, 48);
     this.btnGoUp.Name     = "btnGoUp";
     this.btnGoUp.Size     = new System.Drawing.Size(88, 23);
     this.btnGoUp.TabIndex = 11;
     this.btnGoUp.Text     = "Go Up";
     this.btnGoUp.Click   += new System.EventHandler(this.btnGoUp_Click);
     //
     // btnCapabilities
     //
     this.btnCapabilities.Location = new System.Drawing.Point(408, 88);
     this.btnCapabilities.Name     = "btnCapabilities";
     this.btnCapabilities.Size     = new System.Drawing.Size(88, 23);
     this.btnCapabilities.TabIndex = 12;
     this.btnCapabilities.Text     = "Capabilities";
     this.btnCapabilities.Click   += new System.EventHandler(this.btnCapabilities_Click);
     //
     // btnGetAllProps
     //
     this.btnGetAllProps.Location = new System.Drawing.Point(408, 120);
     this.btnGetAllProps.Name     = "btnGetAllProps";
     this.btnGetAllProps.Size     = new System.Drawing.Size(88, 23);
     this.btnGetAllProps.TabIndex = 13;
     this.btnGetAllProps.Text     = "Get All Props";
     this.btnGetAllProps.Click   += new System.EventHandler(this.btnGetAllProps_Click);
     //
     // btnModifyProp
     //
     this.btnModifyProp.Location = new System.Drawing.Point(408, 152);
     this.btnModifyProp.Name     = "btnModifyProp";
     this.btnModifyProp.Size     = new System.Drawing.Size(88, 23);
     this.btnModifyProp.TabIndex = 14;
     this.btnModifyProp.Text     = "Modify Prop";
     this.btnModifyProp.Click   += new System.EventHandler(this.btnModifyProp_Click);
     //
     // btnMakeDir
     //
     this.btnMakeDir.Location = new System.Drawing.Point(408, 184);
     this.btnMakeDir.Name     = "btnMakeDir";
     this.btnMakeDir.Size     = new System.Drawing.Size(88, 23);
     this.btnMakeDir.TabIndex = 15;
     this.btnMakeDir.Text     = "Make Dir";
     this.btnMakeDir.Click   += new System.EventHandler(this.btnMakeDir_Click);
     //
     // btnDelete
     //
     this.btnDelete.Location = new System.Drawing.Point(408, 216);
     this.btnDelete.Name     = "btnDelete";
     this.btnDelete.Size     = new System.Drawing.Size(88, 23);
     this.btnDelete.TabIndex = 16;
     this.btnDelete.Text     = "Delete";
     this.btnDelete.Click   += new System.EventHandler(this.btnDelete_Click);
     //
     // btnLock
     //
     this.btnLock.Location = new System.Drawing.Point(408, 248);
     this.btnLock.Name     = "btnLock";
     this.btnLock.Size     = new System.Drawing.Size(88, 23);
     this.btnLock.TabIndex = 17;
     this.btnLock.Text     = "Lock Resource";
     this.btnLock.Click   += new System.EventHandler(this.btnLock_Click);
     //
     // btnUnlock
     //
     this.btnUnlock.Location = new System.Drawing.Point(408, 280);
     this.btnUnlock.Name     = "btnUnlock";
     this.btnUnlock.Size     = new System.Drawing.Size(88, 23);
     this.btnUnlock.TabIndex = 18;
     this.btnUnlock.Text     = "Unlock";
     this.btnUnlock.Click   += new System.EventHandler(this.btnUnlock_Click);
     //
     // btnCopyMove
     //
     this.btnCopyMove.Location = new System.Drawing.Point(408, 312);
     this.btnCopyMove.Name     = "btnCopyMove";
     this.btnCopyMove.Size     = new System.Drawing.Size(88, 23);
     this.btnCopyMove.TabIndex = 19;
     this.btnCopyMove.Text     = "Copy / Move";
     this.btnCopyMove.Click   += new System.EventHandler(this.btnCopyMove_Click);
     //
     // btnDownload
     //
     this.btnDownload.Location = new System.Drawing.Point(408, 344);
     this.btnDownload.Name     = "btnDownload";
     this.btnDownload.Size     = new System.Drawing.Size(88, 23);
     this.btnDownload.TabIndex = 20;
     this.btnDownload.Text     = "Download";
     this.btnDownload.Click   += new System.EventHandler(this.btnDownload_Click);
     //
     // btnUpload
     //
     this.btnUpload.Location = new System.Drawing.Point(408, 376);
     this.btnUpload.Name     = "btnUpload";
     this.btnUpload.Size     = new System.Drawing.Size(88, 23);
     this.btnUpload.TabIndex = 21;
     this.btnUpload.Text     = "Upload";
     this.btnUpload.Click   += new System.EventHandler(this.btnUpload_Click);
     //
     // Form1
     //
     this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
     this.ClientSize        = new System.Drawing.Size(512, 414);
     this.Controls.Add(this.btnUpload);
     this.Controls.Add(this.btnDownload);
     this.Controls.Add(this.btnCopyMove);
     this.Controls.Add(this.btnUnlock);
     this.Controls.Add(this.btnLock);
     this.Controls.Add(this.btnDelete);
     this.Controls.Add(this.btnMakeDir);
     this.Controls.Add(this.btnModifyProp);
     this.Controls.Add(this.btnGetAllProps);
     this.Controls.Add(this.btnCapabilities);
     this.Controls.Add(this.btnGoUp);
     this.Controls.Add(this.btnOpen);
     this.Controls.Add(this.lvResources);
     this.Controls.Add(this.label5);
     this.Controls.Add(this.cbDepth);
     this.Controls.Add(this.label4);
     this.Controls.Add(this.edtPassword);
     this.Controls.Add(this.label3);
     this.Controls.Add(this.edtUser);
     this.Controls.Add(this.label2);
     this.Controls.Add(this.edtHost);
     this.Controls.Add(this.label1);
     this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
     this.Name            = "Form1";
     this.StartPosition   = System.Windows.Forms.FormStartPosition.CenterScreen;
     this.Text            = "Web DAV client";
     this.ResumeLayout(false);
     this.PerformLayout();
 }