public void DirectoryEntry_Convert_Binary_Attributes_From_LdapEntry(string attributeName, byte[] attributeValue) { // Prepare directory attribute. var attribute = new DirectoryAttribute { Name = attributeName }; attribute.Add(attributeValue); // Prepare directory entry. var entry = new DirectoryEntry { Attributes = new SearchResultAttributeCollection { attribute } }; // Convert DirectoryEntry to LdapEntry and then back to DirectoryEntry. entry = entry.ToLdapEntry().ToDirectoryEntry(); attribute = entry.GetAttribute(attributeName); // Assert. Assert.Equal(attributeName, attribute.Name); Assert.Equal(attributeValue, attribute.GetValue <byte[]>()); }