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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T18:18:05+00:00 2026-06-03T18:18:05+00:00

I have a pretty extensive application that has been built to provide SSO to

  • 0

I have a pretty extensive application that has been built to provide SSO to several web applications via OID. The problem is that we have seen some users getting “orphaned” on a role for one of the applications. I have written a method that returns the distinguished name for all of the users with access to that role. To perform the cleanup, I am trying to make sure that the users returned in the previous step actually exist in OID. I have been using the System.DirectoryServices.Protocols.SearchRequest class when searching for users or roles, but it is not working for a distinguished name. Below is my method. It has been changed a couple of times to try different ways to make it work.

    Public Function GetUserByDN(UserDN As String) As SearchResultEntry
        Dim searchString As String = String.Format("baseDN={0}", UserDN)
        Dim containerDN As String = Nothing
        If _extranet Then
            containerDN = "cn=users," & ConfigurationManager.AppSettings("Directory_ExternalDomain")
        Else
            containerDN = "cn=users," & ConfigurationManager.AppSettings("Directory_InternalDomain")
        End If

        Dim attributes(14) As String
        attributes(0) = DIRECTORY_UNIQUE_ID
        attributes(1) = DIRECTORY_FIRST_NAME
        attributes(2) = DIRECTORY_LAST_NAME
        attributes(3) = DIRECTORY_EMAIL_ADDRESS
        attributes(4) = DIRECTORY_TELEPHONE
        attributes(5) = DIRECTORY_STREET
        attributes(6) = DIRECTORY_CITY
        attributes(7) = DIRECTORY_STATE
        attributes(8) = DIRECTORY_ZIP
        attributes(9) = DIRECTORY_CUSTOMER_NAME
        attributes(10) = DIRECTORY_ENABLED
        attributes(11) = DIRECTORY_GIVEN_NAME   ' this is the first name for a domain user
        attributes(12) = DIRECTORY_KBIT_INDICATOR
        attributes(13) = DIRECTORY_REQUESTING_BRANCH
        attributes(14) = DIRECTORY_PWD_MUST_CHANGE

        'Me.Connection.Bind()
        Me.Bind()

        Dim myRequest As New System.DirectoryServices.Protocols.SearchRequest(containerDN, UserDN, SearchScope.Base, attributes)
        Dim myResponse As SearchResponse = Me.Connection.SendRequest(myRequest)
        Dim results As SearchResultEntryCollection = myResponse.Entries

        If results.Count >= 1 Then
            Return results(0)
        Else
            Return Nothing
        End If
    End Function
  • 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-03T18:18:06+00:00Added an answer on June 3, 2026 at 6:18 pm

    It has taken a lot of research and asking questions else where to find the answer to this. It turns out that instead of looking in the users OU and searching for the user’s DN, I should have just looked at the user’s DN and just perform a simple LDAP query. Here is my final solution. I hope this helps the community.

           Public Function GetUserByDN(UserDN As String) As SearchResultEntry
            Dim ldapFilter As String = "(objectClass=person)"
    
            Dim attributes(14) As String
            attributes(0) = DIRECTORY_UNIQUE_ID
            attributes(1) = DIRECTORY_FIRST_NAME
            attributes(2) = DIRECTORY_LAST_NAME
            attributes(3) = DIRECTORY_EMAIL_ADDRESS
            attributes(4) = DIRECTORY_TELEPHONE
            attributes(5) = DIRECTORY_STREET
            attributes(6) = DIRECTORY_CITY
            attributes(7) = DIRECTORY_STATE
            attributes(8) = DIRECTORY_ZIP
            attributes(9) = DIRECTORY_CUSTOMER_NAME
            attributes(10) = DIRECTORY_ENABLED
            attributes(11) = DIRECTORY_GIVEN_NAME
            attributes(12) = DIRECTORY_KBIT_INDICATOR
            attributes(13) = DIRECTORY_REQUESTING_BRANCH
            attributes(14) = DIRECTORY_PWD_MUST_CHANGE
    
            Me.Bind()
    
            Dim myRequest As New SearchRequest(UserDN, ldapFilter, SearchScope.Base, attributes)
            Dim myResponse As SearchResponse = Me.Connection.SendRequest(myRequest)
    
            If myResponse.Entries.Count >= 1 Then
                Return myResponse.Entries(0)
            Else
                Return Nothing
            End If
        End Function
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an existing ASP.NET web application that I'm converting to MVC 1.0. The
I'm beginning a project right now that will require a pretty extensive web back
My issue is pretty simple. I have an application that should be executed automatically
I have a Rails 3 application with a pretty standard multipart form that includes
I have pretty much finished my first working Symbian application, but in my hastened
I have pretty big background of .net, and I've decided that i want to
I have built a PHP calendar system and have pretty much everything done but
I have a pretty long running process which now freezes my application for a
I have a large application that currently exists as a hybrid of WebForms and
This has been driving me crazy for a few days now. I have an

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.