Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ internal static int BindToDirectory(ConnectionHandle ld, string who, string pass
passwordPtr = LdapPal.StringToPtr(passwd);
BerVal passwordBerval = new BerVal
{
bv_len = passwd.Length,
bv_len = passwd?.Length ?? 0,
bv_val = passwordPtr,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,16 @@ public void AuthType_SetValid_GetReturnsExpected()
Assert.Equal(AuthType.Basic, connection.AuthType);
}

[Fact]
public void AuthType_Anonymous_DoesNotThrowNull()
{
var connection = new LdapConnection("server");
connection.AuthType = AuthType.Anonymous;
// When calling Bind we make sure that the exception thrown is not that there was a NullReferenceException
// trying to retrive a null password's lenght, but instead an LdapException given the server cannot be reached.
Assert.Throws<LdapException>(() => connection.Bind());
}

[Theory]
[InlineData(AuthType.Anonymous - 1)]
[InlineData(AuthType.Kerberos + 1)]
Expand Down