public void Can_Modify_Individual_Members_Group() { var members = _context.Query <IntegrationUserTest>().Select(u => u.DistinguishedName).ToList(); members.Count.Should().Be.GreaterThan(2); var group = new IntegrationGroupTest { Member = new Collection <string>(members.Skip(1).ToArray()) }; group.SetDistinguishedName("TestGroup"); try { var added = _context.AddAndGet(group); added.Member.Should().Not.Contain(members.First()).And.Have.Count.EqualTo(members.Count - 1); _context.AddAttribute(group.DistinguishedName, "member", members.First()); added = _context.GetByDN <IntegrationGroupTest>(group.DistinguishedName); added.Member.Should().Contain(members.First()).And.Have.Count.EqualTo(members.Count); _context.DeleteAttribute(group.DistinguishedName, "member", members.First()); added = _context.GetByDN <IntegrationGroupTest>(group.DistinguishedName); added.Member.Should().Not.Contain(members.First()).And.Have.Count.EqualTo(members.Count - 1); } finally { try { _context.Delete(group.DistinguishedName); } finally { } } }
/// <summary> /// Executes <see cref="DirectoryContext.DeleteAttribute"/> within a <see cref="Task"/>. /// </summary> /// <param name="context">The context.</param> /// <param name="distinguishedName">The entry</param> /// <param name="attributeName">The name of the attribute</param> /// <param name="controls">Any <see cref="DirectoryControl"/>s to be sent with the request</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="distinguishedName"/> or <paramref name="attributeName"/> is null, empty or white space.</exception> /// <exception cref="DirectoryOperationException">Thrown if the operation fails.</exception> /// <exception cref="LdapConnection">Thrown if the operation fails.</exception> public static Task DeleteAttributeAsync(this IDirectoryContext context, string distinguishedName, string attributeName, params DirectoryControl[] controls) { return(Task.Factory.StartNew(() => context.DeleteAttribute(distinguishedName, attributeName, controls))); }