public void deleteUserFromPermissions(string userSearchPath, contentManagerService1 cmService, string sPath)
        {
            //set searchPath of the required folder
            searchPathMultipleObject spMulti = new searchPathMultipleObject();
            spMulti.Value = sPath;
            folder pFolder = (folder)cmService.query(spMulti, new propEnum[]{propEnum.searchPath,propEnum.policies},new sort[]{},new queryOptions())[0];

            //keep trak if the aecurity object was found in the permissions
            bool found = false;

            for (int i = 0; i < pFolder.policies.value.Length && !found; i ++)
            {
                policy policy = pFolder.policies.value[i];
                //If the security object already exists, update its permissions
                if(policy.securityObject.searchPath.value.Equals(userSearchPath))
                {
                    found = true;
                }
            }
            //if the security object exists, remove it from the array of permissions
            if (found)
            {
                policy[] newPolicies = new policy[pFolder.policies.value.Length-1];
                policyArrayProp pArray = new policyArrayProp();
                for (int i = 0; i < pFolder.policies.value.Length ; i ++)
                {
                    policy policy = pFolder.policies.value[i];
                    if(!policy.securityObject.searchPath.value.Equals(userSearchPath))
                    {
                        newPolicies[i] = new policy ();
                        newPolicies[i].securityObject = pFolder.policies.value[i].securityObject;
                        newPolicies[i].permissions  = pFolder.policies.value[i].permissions;
                    }

                }
                //If the security object does not exist, nothing to delete
                pArray.value = newPolicies;
                pFolder.policies = pArray;
                cmService.update(new baseClass[]{pFolder},new updateOptions() );
            }
        }
        public void setPermissionsOnFolders(string userSearchPath, contentManagerService1 cmService, string sPath)
        {
            searchPathMultipleObject spMulti = new searchPathMultipleObject();
            spMulti.Value = sPath;
            folder pFolder = (folder)cmService.query(spMulti, new propEnum[]{propEnum.searchPath,propEnum.policies},new sort[]{},new queryOptions())[0];

            bool found = false;
            permission newPermission = new permission();
            newPermission.name ="execute";
            newPermission.access = accessEnum.deny;

            for (int i = 0; i < pFolder.policies.value.Length && !found; i ++)
            {
                policy policy = pFolder.policies.value[i];
                //If the security object already exists, update its permissions
                if(policy.securityObject.searchPath.value.Equals(userSearchPath))
                {
                    found = true;
                    permission[] newPerms = new permission[policy.permissions.Length + 1];
                    for(int j = 0; j < policy.permissions.Length; j ++)
                    {
                        newPerms[j] = policy.permissions[j];
                    }
                    newPerms[newPerms.Length - 1] = newPermission;
                    policy.permissions = newPerms;
                }
            }
            //If the security object does not exist, create a new one
            if(!found)
            {
                baseClass entry = null;
                spMulti.Value = userSearchPath;
                entry = cmService.query(spMulti, new propEnum[]{},new sort[]{},new queryOptions())[0];

                policy newPolicy = new policy();
                newPolicy.securityObject = entry;
                permission[] permissions = new permission[1];
                permissions[0] = newPermission;
                newPolicy.permissions = permissions;

                policyArrayProp existingPols = pFolder.policies ;
                policy[] newPols = new policy[existingPols.value.Length + 1];
                for(int j = 0; j < existingPols.value.Length; j ++)
                {
                    newPols[j] = existingPols.value[j];
                }
                newPols[newPols.Length - 1] = newPolicy;
                existingPols.value = newPols;
            }

            cmService.update(new baseClass[]{pFolder},new updateOptions() );
        }