public void When_Serialize_AddRequest()
        {
            var payload = LdapPacketBuilder.NewAddRequest(1, "administrator", (opt) =>
            {
                opt.AddAttribute("objectClass", new List <string>
                {
                    "inetOrgPerson"
                });
            }).Serialize().ToList();
            var ldapPacket = LdapPacket.Extract(payload);
            var addRequest = ldapPacket.ProtocolOperation.Operation as AddRequest;

            Assert.NotNull(ldapPacket);
            Assert.Equal(1, ldapPacket.MessageId.Value);
            Assert.True(addRequest.Attributes.Values.Count() == 1);
            Assert.Equal("objectClass", addRequest.Attributes.Values.First().Type.Value);
        }
Ejemplo n.º 2
0
        public async Task WhenExecuteAddRequest(string dn, int messageId, Table table)
        {
            var payload = LdapPacketBuilder.NewAddRequest(messageId, dn, (opt) =>
            {
                foreach (var record in table.Rows)
                {
                    var key   = record["Key"];
                    var value = record["Value"];
                    opt.AddAttribute(key, new List <string>
                    {
                        value
                    });
                }
            }).Serialize().ToArray();

            await Send(payload);
        }