You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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;
}
}
The text was updated successfully, but these errors were encountered:
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;
}
}
The text was updated successfully, but these errors were encountered: