Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error codes for bindasync seem to all be the same #105

Open
sej69 opened this issue Nov 11, 2020 · 0 comments
Open

Error codes for bindasync seem to all be the same #105

sej69 opened this issue Nov 11, 2020 · 0 comments
Labels

Comments

@sej69
Copy link

sej69 commented Nov 11, 2020

I started writing a method to test authentication and testing (and writing catches) for scenarios that may occur. I then noticed that every error message that pops up seems to be the same hResult but there is a different message. So there doesn't appear to be a way to differentiate between error codes for handling.

Sample code:

public static async Task TestAuthAsync(string szServer, string szAdminName, string szPassword)
{
using (var cn = new LdapConnection())
{
try
{
cn.Timeout = new TimeSpan(0, 0, 30);
cn.Connect("10.1.1.11", 389); // having problems with 636; still working on that...
await cn.BindAsync(LdapAuthMechanism.SIMPLE, szAdminName, szPassword);
}
catch (Exception ex)
{
if (Environment.UserInteractive)
Console.WriteLine(ex.Message);
if (ex.HResult == 2146233088) // <---- same hresult
return AuthReturn.ServerDown;
else if (ex.HResult == 2146233088) // <---- same hresult
return AuthReturn.InvalidCredentials;
}
return AuthReturn.Success;
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants