public override string ToString() { return(string.Format("{0} '{1}' ({2})", AccessControlType.ToString()[0], Account.AccountName, AccessRights.ToString() )); }
public void TestAccessRights() { var expected = new [] { AccessRight.OpenFolder, AccessRight.CreateFolder, AccessRight.DeleteFolder, AccessRight.ExpungeFolder, AccessRight.AppendMessages, AccessRight.SetMessageDeleted }; var rights = new AccessRights(); int i; Assert.IsFalse(rights.IsReadOnly, "IsReadOnly"); Assert.IsTrue(rights.Add(AccessRight.OpenFolder), "Add OpenFolder"); Assert.AreEqual(1, rights.Count, "Count after adding OpenFolder"); Assert.IsFalse(rights.Add(AccessRight.OpenFolder), "Add OpenFolder again"); Assert.AreEqual(1, rights.Count, "Count after adding OpenFolder again"); Assert.IsTrue(rights.Add(AccessRight.CreateFolder.Right), "Add CreateFolder"); Assert.AreEqual(2, rights.Count, "Count after adding CreateFolder"); Assert.IsFalse(rights.Add(AccessRight.CreateFolder), "Add CreateFolder again"); Assert.AreEqual(2, rights.Count, "Count after adding OpenFolder again"); rights.AddRange(new [] { AccessRight.DeleteFolder, AccessRight.ExpungeFolder }); Assert.AreEqual(4, rights.Count, "Count after adding DeleteFolder and ExpungeFolder"); Assert.IsTrue(rights.Contains(AccessRight.DeleteFolder), "Contains DeleteFolder"); Assert.IsTrue(rights.Contains(AccessRight.ExpungeFolder), "Contains ExpungeFolder"); Assert.IsFalse(rights.Contains(AccessRight.Administer), "Contains Administer"); rights.AddRange("it"); Assert.AreEqual(6, rights.Count, "Count after adding AppendMessages and SetMessageDeleted"); Assert.IsTrue(rights.Contains(AccessRight.AppendMessages), "Contains AppendMessages"); Assert.IsTrue(rights.Contains(AccessRight.SetMessageDeleted), "Contains SetMessageDeleted"); Assert.IsFalse(rights.Contains(AccessRight.Administer), "Contains Administer"); for (i = 0; i < 6; i++) { Assert.AreEqual(expected[i], rights[i], "rights[{0}]", i); } ((ICollection <AccessRight>)rights).Add(AccessRight.Administer); Assert.IsTrue(rights.Remove(AccessRight.Administer), "Remove Administer"); Assert.IsFalse(rights.Remove(AccessRight.Administer), "Remove Administer again"); i = 0; foreach (var right in rights) { Assert.AreEqual(expected[i], right, "foreach rights[{0}]", i++); } i = 0; foreach (AccessRight right in ((IEnumerable)rights)) { Assert.AreEqual(expected[i], right, "generic foreach rights[{0}]", i++); } var array = new AccessRight[rights.Count]; rights.CopyTo(array, 0); for (i = 0; i < 6; i++) { Assert.AreEqual(expected[i], array[i], "CopyTo[{0}]", i); } Assert.AreEqual("rkxeit", rights.ToString(), "ToString"); }
/// <summary> /// Checks if current security settings allow DataRequest run particular database operation. If DataRequest has unsufficient access rights - exception will be thrown /// </summary> /// <param name="DesiredAccess">Access rights to check</param> private void AssertHasAccess(AccessRights DesiredAccess) { if ((uint)(this.AllowedAccess & DesiredAccess) == 0) throw new dhtmlxException("Current security settings deny '" + DesiredAccess.ToString() + "' operations over " + this.Adapter.GetType().Name + "!"); }
private async Task <SharedAccessAuthorizationRule> CreateAuthRuleForTopicAsync(string topicName, AccessRights accessRights) { var topicDescription = await this.managementClient.GetTopicAsync(topicName); topicDescription.AuthorizationRules.Clear(); topicDescription.AuthorizationRules.Add(new SharedAccessAuthorizationRule("ruleWith" + accessRights.ToString(), new List <AccessRights> { accessRights })); var updatedTd = await this.managementClient.UpdateTopicAsync(topicDescription); return(updatedTd.AuthorizationRules.FirstOrDefault() as SharedAccessAuthorizationRule); }
public HasNoRightsException(AccessRights rights, FileObject obj) : base($"Для доступа к \"{obj.ToString()}\" недостаточно следующих прав: {rights.ToString()}") { Object = obj; NeededRights = rights; }