Exemplo n.º 1
0
        public void TestPacketPartialAttribute()
        {
            var expected            = "3084000000800204000000016478042d636e3d62696e64557365722c636e3d55736572732c64633d6465762c64633d636f6d70616e792c64633d636f6d3047301804037569643111040f75736572756964676f657368657265302b040b6f626a656374436c617373311c040c616161616161616161616161040c626262626262626262626262";
            var responseEntryPacket = new LdapPacket(1);
            var searchResultEntry   = new LdapAttribute(LdapOperation.SearchResultEntry);

            searchResultEntry.ChildAttributes.Add(new LdapAttribute(UniversalDataType.OctetString, "cn=bindUser,cn=Users,dc=dev,dc=company,dc=com"));   //  objectName

            var partialAttributeList = new LdapAttribute(UniversalDataType.Sequence);



            partialAttributeList.ChildAttributes.Add(new LdapPartialAttribute("uid", "useruidgoeshere"));
            partialAttributeList.ChildAttributes.Add(new LdapPartialAttribute("objectClass", new List <String> {
                "aaaaaaaaaaaa", "bbbbbbbbbbbb"
            }));

            searchResultEntry.ChildAttributes.Add(partialAttributeList);
            responseEntryPacket.ChildAttributes.Add(searchResultEntry);
            var responsEntryBytes = responseEntryPacket.GetBytes();

            Console.WriteLine(Utils.ByteArrayToString(responsEntryBytes));


            var packet = LdapPacket.ParsePacket(responsEntryBytes);

            RecurseAttributes(packet);
            Assert.AreEqual(expected, Utils.ByteArrayToString(packet.GetBytes()));
        }
Exemplo n.º 2
0
        public void TestLdapAttributeParse3()
        {
            var expected    = "30620201026340041164633d636f6d70616e792c64633d636f6d0a01020a010302010202010b010100a31a040e73414d4163636f756e744e616d65040876666f7274656c693000a01b30190417322e31362e3834302e312e3131333733302e332e342e32";
            var packetBytes = Utils.StringToByteArray(expected);
            var packet      = LdapPacket.ParsePacket(packetBytes);

            Assert.AreEqual(expected, Utils.ByteArrayToString(packet.GetBytes()));
        }
Exemplo n.º 3
0
        public void TestLdapAttributeParse()
        {
            var expected    = "30490201016044020103042d636e3d62696e64557365722c636e3d55736572732c64633d6465762c64633d636f6d70616e792c64633d636f6d801062696e645573657250617373776f7264";
            var packetBytes = Utils.StringToByteArray(expected);
            var packet      = LdapPacket.ParsePacket(packetBytes);

            Assert.AreEqual(expected, Utils.ByteArrayToString(packet.GetBytes()));
        }