Skip to content

Commit

Permalink
add UnbindRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
zivillian committed Sep 18, 2018
1 parent 50fe4b8 commit f4df8fe
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
13 changes: 13 additions & 0 deletions ldap.test/DeserializerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,19 @@ public void CanReadSearchRequest2()
Assert.False(control.Value.Value.IsEmpty);
}

[Fact]
public void CanReadUnbindRequest()
{
var data = new byte[]
{
0x30, 0x84, 0x00, 0x00, 0x00, 0x05, 0x02, 0x01,
0x28, 0x42, 0x00
};
var message = Read(data);
Assert.Equal(40, message.Id);
Assert.IsType<LdapUnbindRequest>(message);
}

private LdapRequestMessage Read(byte[] message)
{
return LdapReader.ReadMessage(message.AsMemory());
Expand Down
8 changes: 7 additions & 1 deletion ldap/Asn1/Asn1ProtocolOpChoice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,13 @@ internal struct Asn1ProtocolOpChoice
[ExpectedTag(TagClass.Application, 1)]
public Asn1BindResponse? BindResponse;

//public Asn1UnbindRequest? UnbindRequest;
/*
* UnbindRequest ::= [APPLICATION 2] NULL
*/
[ExpectedTag(TagClass.Application, 2)]
[AnyValue]
//TODO
public ReadOnlyMemory<byte>? UnbindRequest;

[ExpectedTag(TagClass.Application, 3)]
public Asn1SearchRequest? SearchRequest;
Expand Down
4 changes: 4 additions & 0 deletions ldap/LdapRequestMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ internal static LdapRequestMessage Create(Asn1LdapMessage message)
{
return new LdapSearchRequest(message);
}
else if (message.ProtocolOp.UnbindRequest != null)
{
return new LdapUnbindRequest(message);
}
else
{
throw new NotImplementedException();
Expand Down
12 changes: 12 additions & 0 deletions ldap/LdapUnbindRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using zivillian.ldap.Asn1;

namespace zivillian.ldap
{
public class LdapUnbindRequest : LdapRequestMessage
{
internal LdapUnbindRequest(Asn1LdapMessage message)
: base(message)
{
}
}
}

0 comments on commit f4df8fe

Please sign in to comment.