© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
12 replies
reeeeeee

LDAP authentication stopped working for one user

Hey all! I had an LDAP auth implemented on my site, which worked fine for past two years, but randomly stopped working for one user after he changed password.
The code is like this
public bool IsAuthenticated(string ldap, string usr, string pwd)
        {
            bool authenticated = false;

            try
            {
                DirectoryEntry entry = new DirectoryEntry(ldap, usr, pwd);
                object nativeObject = entry.NativeObject;
                authenticated = true;

            }
            catch (DirectoryServicesCOMException cex)
            {
                _logger.Error("DirectoryServicesCOMException occured");
                _logger.Error(cex, cex.StackTrace);
            }
            catch (Exception ex)
            {
                _logger.Error($"Exception occured: {ex.Message}");
                _logger.Error(ex, ex.StackTrace);
            }
            return authenticated;
        }
public bool IsAuthenticated(string ldap, string usr, string pwd)
        {
            bool authenticated = false;

            try
            {
                DirectoryEntry entry = new DirectoryEntry(ldap, usr, pwd);
                object nativeObject = entry.NativeObject;
                authenticated = true;

            }
            catch (DirectoryServicesCOMException cex)
            {
                _logger.Error("DirectoryServicesCOMException occured");
                _logger.Error(cex, cex.StackTrace);
            }
            catch (Exception ex)
            {
                _logger.Error($"Exception occured: {ex.Message}");
                _logger.Error(ex, ex.StackTrace);
            }
            return authenticated;
        }

I am getting returned the username or password is incorrect. Should I implement this better? How can I even debug this? Can I check anything on the AD / LDAP side?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅ SignalR authentication not working
C#CC# / help
2y ago
Services.Configure<T> stopped working?
C#CC# / help
3y ago
❔ SQLite name space stopped working
C#CC# / help
3y ago
❔ Which OAuth packages to choose for 3rd party user authentication?
C#CC# / help
3y ago