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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:03:59+00:00 2026-06-01T13:03:59+00:00

I have a function that will allow me to edit the manager property of

  • 0

I have a function that will allow me to edit the manager property of a user here:

 Public Shared Sub SetManagerProperty(ByVal de As DirectoryEntry, ByVal pName As String, ByVal pValue As String)


        'First make sure the property value isnt "nothing"
        If Not pValue Is Nothing Then
            'Check to see if the DirectoryEntry contains this property already
            If de.Properties.Contains(pName) Then   'The DE contains this property
                'Update the properties value
                de.Properties(pName)(0) = pValue
            Else    'Property doesnt exist
                'Add the property and set it's value

                'de.Properties(pName).Add("cn=" & frmOrganization.txtManagerName.Text & ",OU=Company,OU=Users,OU=Summit,OU=North America,DC=mycompany,DC=com")


            End If
        End If

    End Sub

But what if the manager is not in the Company OU? How can I edit this to search for him in the entire domain?

  • 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-01T13:04:00+00:00Added an answer on June 1, 2026 at 1:04 pm

    Use a DirectorySearcher object

    DirectorySearcher ds = new DirectorySearcher();
    ds.SearchRoot = new DirectoryEntry(String.Format("LDAP://{0}/{1}",adserver,searchroot));
    ds.PropertiesToLoad.Add("distinguishedName");
    ds.SearchScope = SearchScope.Subtree;
    ds.Filter = String.Format("(&(objectCategory=user)(sAMAccountName={0}))", frmOrganization.txtManagerName.Text);
    SearchResult sr = ds.FindOne();
    if (sr == null)
    {
        // Manager does not exist
        return null;
    }
    String managerDN = sr.Properties["distinguishedName"][0].ToString();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to have a function that will return the reverse of a list
I have created a function that will return the string path from my DB.
I have a javascript function that will show the image you're about to upload
I have a binary search function that will search for a word in an
I have problem with fancybox. I want to write a function that will run
I have a php function I wrote that will take a text file and
I have DLL and application that will call some function in this dll. For
I recently learned that all stl containers have swap function: i.e. c1.swap(c2); will lead
I have the following function. The problem is that the $lang variable will vary
I'm working on a page that will allow a user to upload a photo

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.