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

  • Home
  • SEARCH
  • 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 160819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T11:06:10+00:00 2026-05-11T11:06:10+00:00

Is there a way to use a credential coming from the user’s saved password

  • 0

Is there a way to use a credential coming from the user’s saved password list and use that instead of the local Windows credentials?

I need to look up a user’s email address based on their Active Directory username to allow them to register for email updates via an intranet site. This seems easy enough if the user is actually logged into a machine directly that’s part of the domain – I can use their identity name to search the AD based on their username:

using( DirectoryEntry root = new DirectoryEntry('LDAP://admachine.domain.local') ) {   using( DirectorySearcher searcher = new DirectorySearcher(root) )   {     // strip the domain from the username and find the user in AD     var username = Regex.Replace(Page.User.Identity.Name, @'.*\\', string.Empty);     searcher.ReferralChasing = ReferralChasingOption.All;     searcher.SearchScope = SearchScope.Subtree;     searcher.Filter = string.Format('(&(objectCategory=user)(objectClass=person)(sAMAccountName={0}))', username);     var foundUser = searcher.FindOne();      // error checking occurs here...     var email = foundUser.Properties['mail'][0].ToString();      // TODO: stuff with the email address   } } 

However, if working from a PC at home this doesn’t work. Page.Identity.Name resolves to the name I’m logged onto my own PC (MyMachine\Dave), ignoring stored credentials I used to authenticate with my work domain (WorkDomain\dave.downs).

The DirectoryEntry picks up and uses the saved credential just fine, allowing me to actually bind to and search the AD, but I can’t find a way of then using it as the var username, which will contain of my local machine username instead.

Is there a way to actually do what I’m trying to do, or am I just going about things the wrong way/hitting my head against a brick wall?

  • 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. 2026-05-11T11:06:10+00:00Added an answer on May 11, 2026 at 11:06 am

    I assume you are using IIS. Disable Anonymous Access and enable windows authentication. That way anybody who is not in the domain will get a popup that allows them to specify their domain user and password. For users that are coming from a domain enabled server nothing changes. But that way you guarantee that the identity will always resolve to a valide domain user. So this should solve your ‘I am seeing a non-domain user’ problem. Check Windows Authentication Provider for details.

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

Sidebar

Ask A Question

Stats

  • Questions 68k
  • Answers 69k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer There are no explicit page breaks in RTF files, unless… May 11, 2026 at 12:25 pm
  • added an answer You should definitely use the FindAll method, or the equivalent… May 11, 2026 at 12:25 pm
  • added an answer public static int ExcelColumnNameToNumber(string columnName) { if (string.IsNullOrEmpty(columnName)) throw new… May 11, 2026 at 12:25 pm

Related Questions

Is there a way to use a foreach loop to iterate through a collection
Is there a way to use (reference) a DLL written in an unmanaged C++
Is there a way to force use of a named route in ASP.NET MVC
I'm going around in circles with regards to WCF and security, so I'm listing
How can I protect a ClickOnce deployed application with a password ? Do I
I'm currently using a PHPBB2 forum for a section of one of my sites,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.