Exemplo n.º 1
0
        public void DeleteSubTree()
        {
            var container = new DirectoryAttributes("CN=DeleteContainer,CN=Employees,DC=Northwind,DC=local");

            container.Set("objectClass", new[] { "top", "container" });

            _context.Add(container);

            var attributes = new DirectoryAttributes("CN=IntegrationTest," + container.DistinguishedName);

            attributes.SetNull("AccountExpires");
            attributes.Set("objectclass", "user");

            _context.AddAndGet(attributes);

            _context.Delete(container.DistinguishedName, new TreeDeleteControl());

            Executing.This(() => _context.GetByDN(container.DistinguishedName))
            .Should().Throw <DirectoryOperationException>().And.Exception.Message
            .Should().Contain("does not exist");
        }
Exemplo n.º 2
0
        public void Can_Add_Update_Remove_Dynamic()
        {
            var attributes = new DirectoryAttributes("CN=IntegrationTest," + IntegrationUserTest.NamingContext);

            attributes.SetNull("AccountExpires");
            attributes.Set("objectclass", "user");

            var added = _context.AddAndGet(attributes);

            added.Should().Not.Be.Null();

            added.GetString("cn").Should().Be.EqualTo("IntegrationTest");
            added.GetString("accountexpires").Should().Be.Null();
            added.GetGuid("objectguid").Should().Have.Value();
            added.GetSecurityIdentifier("objectsid").Should().Not.Be.Null();
            added.GetSecurityIdentifiers("objectsid").Should().Not.Be.Empty();
            added.GetStrings("objectclass").Should().Have.Count.GreaterThan(1);

            added.Set("accountExpires", "9223372036854775807").SetNull("manager");

            added = _context.UpdateAndGet(added);

            added.GetString("accountExpires").Should().Be.EqualTo("9223372036854775807");
            added.GetDateTime("accountExpires", null).Should().Not.Have.Value();
            added.GetString("manager").Should().Be.Null();

            var renamed = _context.RenameEntry(added.DistinguishedName, "IntegrationTest2");

            var moved = _context.MoveEntry(renamed, IntegrationUserTest.NamingContext2);

            _context.Delete(moved);

            Executing.This(() => _context.GetByDN(moved))
            .Should().Throw <DirectoryOperationException>().And.Exception.Message
            .Should().Contain("does not exist");
        }