Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8676421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:11:30+00:00 2026-06-12T20:11:30+00:00

I am looking up an arbitrary Windows account in a forms-based C# login scenario

  • 0

I am looking up an arbitrary Windows account in a forms-based C# login scenario using the user’s e-mail address as the key. Locating the user works fine and I get back my derived UserPrincipalEx fine.

However, when I try to validate a login using a Bind, it always succeeds:

// we can't use ValidateCredentials because it's too broken - multiple attempts each time,
// can't always negotiate properly, etc.
//if (!_principalContext.ValidateCredentials(userPrincipal.UserPrincipalName, password)) {
//    return LoginValidationResults.ValidationFailed;
//}
try {
    using (var directoryEntry = new DirectoryEntry("LDAP://" + _domain + "/" + _principalContext.Container,
        userPrincipal.UserPrincipalName, password, AuthenticationTypes.FastBind)) {
        var forceBind = directoryEntry.NativeObject;
        Log.DebugFormat("Validation successful ({0}).", forceBind);
        return LoginValidationResults.Valid;
    }                    
}
catch (COMException ex) {
    if (ex.ErrorCode != -2147023570) {
        Log.DebugFormat("Validation exception: {0}", ex.ToString());
        throw;
    }
    Log.Debug("Validation failed.");
    return LoginValidationResults.ValidationFailed;
}

In some cases – and I can’t figure out what they are yet – the account always binds successfully, no matter what password I give.

Why could this be?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T20:11:32+00:00Added an answer on June 12, 2026 at 8:11 pm

    So I looked into this using some packet captures and saw that all of the succeeding binds were using a blank username.

    Sure enough, the users in question had a blank (actually null – not set) UPN. This should never happen in our scenario but it did. Because it’s a broken user case, I just detect that and throw an exception.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am looking for a way to embed Windows Forms applications written in C#
I am looking at whether it is possible to execute arbitrary SQL commands (dynamic
I'm looking for a way to send the output of an arbitrary Emacs command
I'm looking for an elegant and efficient way to represent and store an arbitrary
Looking to do a bit of refactoring... Using NHibernate I have this query currently
Looking at the Slickgrid examples and using Google Chrome, I'm setting a breakpoint on
I'm looking for a way to show/hide an arbitrary RichFaces component. In this case,
I have been looking for a portable method to digitally sign arbitrary text which
I have some text looking like this: My arbitrary content.... ```c# public class Foo
I'm looking for an algorithm that would move a point around an arbitrary closed

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.