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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:05:31+00:00 2026-05-13T21:05:31+00:00

I have a web app (.NET 3.5) which is sending notifications by email to

  • 0

I have a web app (.NET 3.5) which is sending notifications by email to users. In order to do this, I search Active Directory to find each person’s email.

At the moment, I am hardcoding my own username and password like so in order to search AD:

    Dim entry As New DirectoryEntry("LDAP://companyad", "myUsername", "myPassword", AuthenticationTypes.Secure)
    Dim srch As New DirectorySearcher(entry)
    srch.Filter = [String].Format("(&(objectClass=person)(sAMAccountName={0}))", "someOtherUsername")
    Dim result As SearchResult = srch.FindOne()

Now, obviously, this is not ideal and I don’t want those credentials hardcoded. My web app is using Windows Authentication. It also uses impersonation (as the logged in user) to access files and SQL Server. Is there also a way for me to “impersonate” the logged in user in order to search AD?

EDIT 1

I thought I’d better explain why I chose this answer. The problem turned out to not be the multi-hop issue or kerberos as it seems I have set these up correctly.

I had recently changed my app to only allow access to a certain group through the web.config settings. I had previously been only allowing access to myself. I set up the group and added myself to it. I then removed the hardcoded credentials and attempted to run the app WITHOUT RESTARTING my computer.

According to my network admin, I would not be logged on under that new group until I restarted my computer which I think is what was causing my problem. So, Preet’s answer is actually the most accurate as I just needed to pass the LDAP path to DirectoryEntry.

EDIT 2

I also needed to register a Service Principal Name.

I ran this:

setspn -A HTTP/[dns name of the site] [machine name]

on my development machine.

Thanks to everyone else for their answers.

  • 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-13T21:05:31+00:00Added an answer on May 13, 2026 at 9:05 pm

    Doesn’t

    Dim entry As New DirectoryEntry("LDAP://companyad")
    

    work?

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

Sidebar

Related Questions

I have an asp.net web app which holds its data in an sql server
I have an ASP.NET MVC web app which includes the facility for clients to
I have a web app (ASP.net with VB.net) that will run on one of
I have a .net web app hosting in IIS6 with Windows Authentication and anonymous
I have a .NET 3.5 web application which has a set of classes handling
I have created a data access layer in my web app which uses ObjectDataSource
I'm writing a function for a web app in ASP.NET where the client logs
I want to totally remove the standard ASP.NET membership system and use Facebook only
I am trying to check how much time does a function takes to execute
I need to capture user's X.509 certificates from their cards and map to a

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.