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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T00:59:51+00:00 2026-05-12T00:59:51+00:00

Each of our users is assigned to a primary organizational unit (OU) based on

  • 0

Each of our users is assigned to a primary organizational unit (OU) based on which global office they are in. So the “Chicago” OU contains all the associates in our Chicago office.

Using c# and .net 3.5, my task is to extract all of these users.

Unless the users are in a satellite or home office, their street address, city, state, etc. are empty, but the OU contains these details. When in Windows’ Active Directory interface, right clicking on the OU and selecting properties gives a place to put all of this information just as on a user. However, when I try to access these properties like I do a user, I get an object reference error, suggesting these attributes do not exist the same way for an OU that they do for a user.

How do/can I access these location parameters from an OU object?

Here is a sample of the code I am using, showing streetaddress as an example, the statement trying to assign the value of streetaddress from the OU fails, where the assignment from associate succeeds.

foreach (SearchResult subOU in results)
{
   ResultPropertyValueCollection subColl = subOU.Properties["distinguishedname"];
   string subPath = subColl[0].ToString();
   DirectoryEntry subEntry = new DirectoryEntry("LDAP://" + subPath);
   DirectorySearcher userSearcher = new DirectorySearcher(subEntry);
   userSearcher.SearchScope = SearchScope.OneLevel;
   userSearcher.Filter = "(objectClass=user)";
   foreach (SearchResult user in userSearcher.FindAll())
   {
     ResultPropertyValueCollection userColl = user.Properties["distinguishedname"];
     string userPath = userColl[0].ToString();
     DirectoryEntry userEntry = new DirectoryEntry("LDAP://" + userPath);
     PropertyCollection associateProperties = userEntry.Properties;
     PropertyCollection ouProperties = subEntry.Properties;

     string streetAddress = string.Empty;
     if (associateProperties["streetaddress"].Value == null) 
     { streetAddress = ouProperties["streetaddress"].Value.ToString(); }
     else
     { streetAddress = associateProperties["streetaddress"].Value.ToString(); }
  }
}
  • 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-12T00:59:51+00:00Added an answer on May 12, 2026 at 12:59 am

    If you change the Street-field on the General-tab in Active Directory Users & Computers for a user the value is stored in the streetAddress-attribute in the directory. If however you change the same field for an OU that value is stored in the street-attribute of that OU in the directory.

    This is because OU objects are not (as defined in the Active Directory default schema) permitted to contain the streetAddress-attribute.

    So (not having analyzed your code further) if you change ouProperties["streetaddress"] to ouProperties["street"] you’ll might get the result you’re looking for.

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

Sidebar

Related Questions

I have a site 'accounts' table which contains account details for all our users.
I'm logging different actions users make on our website. Each action can be of
We have a website that contains a database of places. For each place our
A small number of our users are experiencing an error when they try to
We currently have a system where each of our users gets a database. We
I'm trying to aggregate a bunch of user profile data in our app. Each
We're currently building multiple copies of our Chrome CRX, one for each of our
We are using Visual Studio 2010 and before each release to our test server
Our production environment runs 3 32-Bit Java 6 JVMs on each Windows 2003 server.
We deploy our .net web application in six server(each with one copy) to get

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.