/// <summary>
        /// Validate if User has related permissions according to the permission level set on folder.
        /// </summary>
        /// <param name="permissionLevel">Permission level value.</param>
        protected void ValidateFolderPermissionLevel(PermissionLevelType permissionLevel)
        {
            #region Create a folder in the User1's inbox folder, and set permission level value for User2

            // Configure permission set.
            PermissionSetType permissionSet = new PermissionSetType();
            permissionSet.Permissions = new PermissionType[1];
            permissionSet.Permissions[0] = new PermissionType();
            permissionSet.Permissions[0].PermissionLevel = permissionLevel;
            permissionSet.Permissions[0].UserId = new UserIdType();
            permissionSet.Permissions[0].UserId.PrimarySmtpAddress = Common.GetConfigurationPropertyValue("User2Name", this.Site) + "@" + Common.GetConfigurationPropertyValue("Domain", this.Site);

            // CreateFolder request.
            CreateFolderType createFolderRequest = this.GetCreateFolderRequest(DistinguishedFolderIdNameType.inbox.ToString(), new string[] { "Custom Folder" }, new string[] { "IPF.MyCustomFolderClass" }, new PermissionSetType[] { permissionSet });

            // Create a new folder.
            CreateFolderResponseType createFolderResponse = this.FOLDAdapter.CreateFolder(createFolderRequest);
            Site.Assert.AreEqual<ResponseClassType>(ResponseClassType.Success, createFolderResponse.ResponseMessages.Items[0].ResponseClass, "Fold should be created successfully!");

            // Save the new created folder's folder id.
            FolderIdType newFolderId = ((FolderInfoResponseMessageType)createFolderResponse.ResponseMessages.Items[0]).Folders[0].FolderId;
            this.NewCreatedFolderIds.Add(newFolderId);

            #endregion

            #region Create an item in the folder created in step 1 with User1's credential

            string itemNameNotOwned = Common.GenerateResourceName(this.Site, "Test Mail");

            // Create an item in the new created folder.
            ItemIdType itemIdNotOwned = this.CreateItem(Common.GetConfigurationPropertyValue("User1Name", Site) + "@" + Common.GetConfigurationPropertyValue("Domain", Site), newFolderId.Id, itemNameNotOwned);
            Site.Assert.IsNotNull(itemIdNotOwned, "Item should be created successfully!");

            #endregion

            #region Switch to User2

            this.SwitchUser(Common.GetConfigurationPropertyValue("User2Name", this.Site), Common.GetConfigurationPropertyValue("User2Password", this.Site), Common.GetConfigurationPropertyValue("Domain", this.Site));

            #endregion

            #region Create a subfolder under the folder created in step 1 with User2's credential

            // CreateFolder request.
            CreateFolderType createFolderInSharedMailboxRequest = this.GetCreateFolderRequest(newFolderId.Id, new string[] { "Custom Folder" }, new string[] { "IPF.MyCustomFolderClass" }, null);

            // Create a new folder.
            CreateFolderResponseType createFolderInSharedMailboxResponse = this.FOLDAdapter.CreateFolder(createFolderInSharedMailboxRequest);

            this.CanCreateSubFolder = ResponseClassType.Success == createFolderInSharedMailboxResponse.ResponseMessages.Items[0].ResponseClass;

            #endregion

            #region Edit items that User2 doesn't own with User2's credential

            this.CanEditNotOwnedItem = this.UpdateItemSubject(itemIdNotOwned);
            this.CanReadNotOwnedItem = this.GetItem(itemIdNotOwned);
            this.CanDeleteNotOwnedItem = this.DeleteItem(itemIdNotOwned);

            #endregion

            #region Edit items that User2 owns with User2's credential

            string itemNameOwned = Common.GenerateResourceName(this.Site, "Test Mail");
            string user1MailBox = Common.GetConfigurationPropertyValue("User1Name", Site) + "@" + Common.GetConfigurationPropertyValue("Domain", Site);

            ItemIdType itemIdOwned = this.CreateItem(user1MailBox, newFolderId.Id, itemNameOwned);

            // If user can create items.
            this.CanCreateItem = itemIdOwned != null;
            if (this.CanCreateItem)
            {
                this.CanEditOwnedItem = this.UpdateItemSubject(itemIdOwned);
                this.CanReadOwnedItem = this.GetItem(itemIdOwned);
                this.CanDeleteOwnedItem = this.DeleteItem(itemIdOwned);
            }

            #endregion

            #region Switch to User1

            this.SwitchUser(Common.GetConfigurationPropertyValue("User1Name", this.Site), Common.GetConfigurationPropertyValue("User1Password", this.Site), Common.GetConfigurationPropertyValue("Domain", this.Site));

            #endregion
        }
Example #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PermissionLevelGridModel" /> class.
 /// </summary>
 /// <param name="id">id.</param>
 /// <param name="name">name.</param>
 /// <param name="type">type.</param>
 /// <param name="description">description.</param>
 public PermissionLevelGridModel(Guid id = default(Guid), string name = default(string), PermissionLevelType type = default(PermissionLevelType), string description = default(string))
 {
     this.Id          = id;
     this.Name        = name;
     this.Type        = type;
     this.Description = description;
 }