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 7604779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:59:52+00:00 2026-05-30T23:59:52+00:00

I am using C# application to authenticate and check Active Directory user which locates

  • 0

I am using C# application to authenticate and check Active Directory user which locates on a Window 2008 64 bit server.

I was able to authenticate a user successfully when supplying the user name and password using the following code: My domainName value is rootforest.com and my userName is admin6

        UserPrincipal usr;
        PrincipalContext ad;

        //Enter Active Directory settings
        ad = new PrincipalContext(ContextType.Domain, domainName,usrName,pswd);

        //search user
        usr = new UserPrincipal(ad);
        usr.SamAccountName = usrName;

        PrincipalSearcher search = new PrincipalSearcher(usr);
        usr = (UserPrincipal)search.FindOne();
        search.Dispose();

In another function where I want to check if user ‘admin6’ exists and I don’t have the password, but when I check it the function keep throwing “Logon failire: unkoown user name or bad password. \r\n”. The code I used was almost identical to the above except this line:

        //Enter Active Directory settings
        ad = new PrincipalContext(ContextType.Domain, domainName);

Having this not working, I’ve tried other code I found on the web but they all give me the same error. I begun to think it could be how I set up my Active Directory domain?

The picture below is how my domain looks:

https://picasaweb.google.com/100922945973553878191/ActiveDirectory?authuser=0&feat=directlink

Can anyone assist me with this? I’ve been stuck with this issue for last day or so now and I can’t seem to find out why. If you have some codes I can try it would be great

  • 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-05-30T23:59:54+00:00Added an answer on May 30, 2026 at 11:59 pm

    To check whether the user exists, your code must execute a base-level search using the known distinguished name. If the results of the search are successful and the number of entries returned as part of the search result are greater than 1, then the distinguished name exists in the directory database.

    This is different from establishing the authentication state of a connection which is accomplished with a bind request. If the bind request is successful, then the connection’s authentication state is set according to the distinguished name used in the bind.

    Perhaps you should check the status of the distinguished name using the command line ldapsearch tool. This will allow you to be confident that the distinguished name exists, and also if the credentials are correct, and also that directory permissions allow for what you are trying to accomplish. Once you have satisfied yourself as to the existence of the distinguished name and the credentials, you can proceed with troubleshooting your code.

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

Sidebar

Related Questions

I am writing an application which has an authenticity mechanism, using HMAC-sha1, plus a
I distribute my application using a VS2008 install package, which normally works great. When
I'm writing application which consists of server side on Google App Engine (Java) and
Hi I am using php on server side, once I authenticate flex channel set
I've got a web application, deployed on GlassFish 3.0.1, which is using container managed
Im using asp.net 4.0 and Form auth. To check if a user is authenticated
I have a .NET MVC (1.0) application that is using the ActiveDirectoryMembershipProvider to authenticate
In our asp.net intranet application we are using windows authentication to authenticate the users.
I am using apache shiro to authenticate a user and i want to simply
I need to check if an authenticated user is authorized to access a directory.

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.