Ejemplo n.º 1
0
        public void CreateWebDavRule(string organizationId, string folder, WebDavFolderRule rule)
        {
            using (ServerManager serverManager = new ServerManager())
            {
                Configuration config = serverManager.GetApplicationHostConfiguration();

                ConfigurationSection authoringRulesSection = config.GetSection("system.webServer/webdav/authoringRules", string.Format("{0}/{1}/{2}", _Setting.Domain, organizationId, folder));

                ConfigurationElementCollection authoringRulesCollection = authoringRulesSection.GetCollection();

                ConfigurationElement addElement = authoringRulesCollection.CreateElement("add");

                if (rule.Users.Any())
                {
                    addElement["users"] = string.Join(", ", rule.Users.Select(x => x.ToString()).ToArray());
                }

                if (rule.Roles.Any())
                {
                    addElement["roles"] = string.Join(", ", rule.Roles.Select(x => x.ToString()).ToArray());
                }

                if (rule.Pathes.Any())
                {
                    addElement["path"] = string.Join(", ", rule.Pathes.ToArray());
                }

                addElement["access"] = rule.AccessRights;
                authoringRulesCollection.Add(addElement);

                serverManager.CommitChanges();
            }
        }
Ejemplo n.º 2
0
        public void CreateWebDavRule(string organizationId, string folder, WebDavFolderRule rule)
        {
            using (ServerManager serverManager = new ServerManager())
            {
                Configuration config = serverManager.GetApplicationHostConfiguration();

                ConfigurationSection authoringRulesSection = config.GetSection("system.webServer/webdav/authoringRules", string.Format("{0}/{1}/{2}", _Setting.Domain, organizationId, folder));

                ConfigurationElementCollection authoringRulesCollection = authoringRulesSection.GetCollection();

                ConfigurationElement addElement = authoringRulesCollection.CreateElement("add");

                if (rule.Users.Any())
                {
                    addElement["users"] = string.Join(", ", rule.Users.Select(x => x.ToString()).ToArray());
                }

                if (rule.Roles.Any())
                {
                    addElement["roles"] = string.Join(", ", rule.Roles.Select(x => x.ToString()).ToArray());
                }

                if (rule.Pathes.Any())
                {
                    addElement["path"] = string.Join(", ", rule.Pathes.ToArray());
                }

                addElement["access"] = rule.AccessRights;
                authoringRulesCollection.Add(addElement);

                serverManager.CommitChanges();
            }
        }
Ejemplo n.º 3
0
        public bool DeleteWebDavRule(string organizationId, string folder, WebDavFolderRule rule)
        {
            using (ServerManager serverManager = new ServerManager())
            {
                Configuration config = serverManager.GetApplicationHostConfiguration();

                ConfigurationSection authoringRulesSection = config.GetSection("system.webServer/webdav/authoringRules", string.Format("{0}/{1}/{2}", _Setting.Domain, organizationId, folder));

                ConfigurationElementCollection authoringRulesCollection = authoringRulesSection.GetCollection();

                var toDeleteRule = authoringRulesCollection.FindWebDavRule(rule);

                if (toDeleteRule != null)
                {
                    authoringRulesCollection.Remove(toDeleteRule);
                    serverManager.CommitChanges();
                    return(true);
                }
                return(false);
            }
        }
Ejemplo n.º 4
0
        public bool DeleteWebDavRule(string organizationId, string folder, WebDavFolderRule rule)
        {
            using (ServerManager serverManager = new ServerManager())
            {
                Configuration config = serverManager.GetApplicationHostConfiguration();

                ConfigurationSection authoringRulesSection = config.GetSection("system.webServer/webdav/authoringRules", string.Format("{0}/{1}/{2}", _Setting.Domain, organizationId, folder));

                ConfigurationElementCollection authoringRulesCollection = authoringRulesSection.GetCollection();

                var toDeleteRule = authoringRulesCollection.FindWebDavRule(rule);

                if (toDeleteRule != null)
                {
                    authoringRulesCollection.Remove(toDeleteRule);
                    serverManager.CommitChanges();
                    return true;
                }
                return false;
            }
        }
        private static UserPermission[] ConvertToUserPermissions(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 user in rule.Roles)
                {
                    users.Add(new UserPermission
                    {
                        AccountName = user,
                        Read = rule.Read,
                        Write = rule.Write
                    });
                }
            }

            return users.ToArray();
        }
        private static ESPermission[] ConvertToESPermission(int itemId, WebDavFolderRule[] rules)
        {
            var permissions = new List<ESPermission>();

            foreach (var rule in rules)
            {
                var permission = new ESPermission();

                permission.Account = rule.Users.Any() ? rule.Users[0] : rule.Roles[0];

                permission.IsGroup = rule.Roles.Any();

                var orgObj = OrganizationController.GetAccountByAccountName(itemId, permission.Account);

                if (orgObj == null)
                    continue;

                if (permission.IsGroup)
                {
                    var secGroupObj = OrganizationController.GetSecurityGroupGeneralSettings(itemId, orgObj.AccountId);

                    if (secGroupObj == null)
                        continue;

                    permission.DisplayName = secGroupObj.DisplayName;

                }
                else
                {
                    var userObj = OrganizationController.GetUserGeneralSettings(itemId, orgObj.AccountId);

                    if (userObj == null)
                        continue;

                    permission.DisplayName = userObj.DisplayName;
                }

                if (rule.Read && !rule.Write)
                {
                    permission.Access = "Read-Only";
                }
                if (rule.Write)
                {
                    permission.Access = "Read-Write";
                }

                permissions.Add(permission);
            }

            return permissions.ToArray();

        }
        private static WebDavFolderRule[] ConvertToWebDavRule(int itemId, ESPermission[] permissions)
        {
            var rules = new List<WebDavFolderRule>();

            foreach (var permission in permissions)
            {
                var rule = new WebDavFolderRule();

                var account = ObjectUtils.FillObjectFromDataReader<ExchangeAccount>(DataProvider.GetExchangeAccountByAccountName(itemId, permission.Account));

                if (account.AccountType == ExchangeAccountType.SecurityGroup
                    || account.AccountType == ExchangeAccountType.DefaultSecurityGroup)
                {
                    rule.Roles.Add(permission.Account);
                    permission.IsGroup = true;
                }
                else
                {
                    rule.Users.Add(permission.Account);
                }

                if (permission.Access.ToLower().Contains("read-only"))
                {
                    rule.Read = true;
                }

                if (permission.Access.ToLower().Contains("read-write"))
                {
                    rule.Write = true;
                    rule.Read = true;
                    rule.Source = true;
                }

                rule.Source = true;

                rule.Pathes.Add("*");

                rules.Add(rule);
            }

            return rules.ToArray();
        }
 /// <remarks/>
 public void SetFolderWebDavRulesAsync(string organizationId, string folder, WebDavSetting setting, WebDavFolderRule[] rules, object userState) {
     if ((this.SetFolderWebDavRulesOperationCompleted == null)) {
         this.SetFolderWebDavRulesOperationCompleted = new System.Threading.SendOrPostCallback(this.OnSetFolderWebDavRulesOperationCompleted);
     }
     this.InvokeAsync("SetFolderWebDavRules", new object[] {
                 organizationId,
                 folder,
                 setting,
                 rules}, this.SetFolderWebDavRulesOperationCompleted, userState);
 }
 /// <remarks/>
 public void SetFolderWebDavRulesAsync(string organizationId, string folder, WebDavSetting setting, WebDavFolderRule[] rules) {
     this.SetFolderWebDavRulesAsync(organizationId, folder, setting, rules, null);
 }
 /// <remarks/>
 public System.IAsyncResult BeginSetFolderWebDavRules(string organizationId, string folder, WebDavSetting setting, WebDavFolderRule[] rules, System.AsyncCallback callback, object asyncState) {
     return this.BeginInvoke("SetFolderWebDavRules", new object[] {
                 organizationId,
                 folder,
                 setting,
                 rules}, callback, asyncState);
 }
 public bool SetFolderWebDavRules(string organizationId, string folder, WebDavSetting setting, WebDavFolderRule[] rules) {
     object[] results = this.Invoke("SetFolderWebDavRules", new object[] {
                 organizationId,
                 folder,
                 setting,
                 rules});
     return ((bool)(results[0]));
 }
Ejemplo n.º 12
0
        public bool SetFolderWebDavRules(string organizationId, string folder, WebDavFolderRule[] newRules)
        {
            try
            {
                if (DeleteAllWebDavRules(organizationId, folder))
                {
                    if (newRules != null)
                    {
                        foreach (var rule in newRules)
                        {
                            CreateWebDavRule(organizationId, folder, rule);
                        }
                    }

                    return true;
                }
            }
            catch {  }
            return false;
        }
Ejemplo n.º 13
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);
        }