Example #1
0
        public void Delete_OfExistingEntry_ShouldWork()
        {
            var existingEntry = LdapOps.AddEntry();

            TestHelper.WithAuthenticatedLdapConnection(ldapConnection => { ldapConnection.Delete(existingEntry.Dn); });

            var retrivedEntry = LdapOps.GetEntry(existingEntry.Dn);

            Assert.Null(retrivedEntry);
        }
        public void AddEntry_NotExisting_ShouldWork()
        {
            var ldapEntry = LdapEntryHelper.NewLdapEntry();

            TestHelper.WithAuthenticatedLdapConnection(ldapConnection => { ldapConnection.Add(ldapEntry); });

            var readEntry = LdapOps.GetEntry(ldapEntry.Dn);

            ldapEntry.AssertSameAs(readEntry);
        }
        public void AddNewAttribute_ToExistingEntry_ShouldWork()
        {
            var          existingEntry = LdapOps.AddEntry();
            var          value         = Guid.NewGuid().ToString();
            const string attrName      = "description";

            TestHelper.WithAuthenticatedLdapConnection(ldapConnection =>
            {
                var newAttribute = new LdapAttribute(attrName, value);
                var modification = new LdapModification(LdapModification.ADD, newAttribute);
                ldapConnection.Modify(existingEntry.DN, modification);
            });

            var modifiedEntry = LdapOps.GetEntry(existingEntry.DN);

            Assert.Equal(value, modifiedEntry.getAttribute(attrName).StringValue);
        }
        public void ModifyAttributeValue_OfExistingEntry_ShouldWork()
        {
            var          existingEntry = LdapOps.AddEntry();
            var          value         = Guid.NewGuid().ToString();
            const string attrName      = "givenName";

            TestHelper.WithAuthenticatedLdapConnection(ldapConnection =>
            {
                var modifiedAttribute = new LdapAttribute(attrName, value);
                var modification      = new LdapModification(LdapModification.Replace, modifiedAttribute);
                ldapConnection.Modify(existingEntry.Dn, modification);
            });

            var modifiedEntry = LdapOps.GetEntry(existingEntry.Dn);

            Assert.Equal(value, modifiedEntry.GetAttribute(attrName).StringValue);
        }
Example #5
0
        public void Rename_ExistingEntry_ShouldWork()
        {
            var entry = LdapOps.AddEntry();
            var newCn = Guid.NewGuid().ToString();

            TestHelper.WithAuthenticatedLdapConnection(ldapConnection =>
            {
                ldapConnection.Rename(entry.Dn, "cn=" + newCn, true);
            });

            Assert.Null(LdapOps.GetEntry(entry.Dn));
            var renamedEntry = LdapOps.GetEntry(TestHelper.BuildDn(newCn));

            Assert.NotNull(renamedEntry);
            entry.GetAttributeSet().AssertSameAs(renamedEntry.GetAttributeSet(), new List <string> {
                "cn"
            });
        }