473,786 Members | 2,451 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Retrieving Active Directory Hierarchies through ASP.NET and C#

3 New Member
Hello Guys,

I am developing a web application to manage Active Directory resources, and one of my tasks is to map Organizational Units hierarchy into a SQL Server database. Let's suppose that I have the following OU hierarchy in my Active Direcoty:

1. NewYork
-----1.1 HR_Department
----------1.1.1 Computers
----------1.1.2 Users
-----1.2 SALES_Departmen t
----------1.2.1 Computers
----------1.2.2 Users
-----1.3 So on.....
2. Chicago
-----2.1 HR_Department
----------1.1.1 Computers
----------1.1.2 Users
-----2.2 SALES_Departmen t
----------2.1.1 Computers
----------2.1.2 Users
-----2.3 So on....

I designed the following table into SQL Server in order to reach the AD hierarchy:

OUId INT
// Just an integer ID to identify the row.

OUName VARCHAR(50)
// Name of OU that comes from AD.

ParentOUId INT
// Id of the parent OU to create as many levels as necessary.

The idea is to create a recursive table to store the hierarchy in a flexible way that there won't be any limitations in terms of creating as many sub OU as necessary. At this point goes my issue: I am having problems to create a C# function to return whether a OU already exists or not.

Unfortunately Active Directory does not provide me a property that indicates who is parent OU. I can only identify the object structure by the distinguishedNa me property, which acording to my example returns something like:

OU=Computers,OU =HR_Deparment, OU=NewYork, DC=....

From this string, I convert it to an array:

[0] Computers
[1] HR_Department
[2] NewYork

From now on, I am stuck. I don't know how to create a recursive function to return and create the AD Hierarchy in my context.


Could anyone help handle this?

Thank you very much for you attention!
Jul 18 '08 #1
0 1358

Sign in to post your reply or Sign up for a free account.

Similar topics

0
2785
by: microsoft | last post by:
Hi People, when I try to modify an active directory user programatically, I receive the following exception: The server is unwilling to process the request Reading the microsoft web site, I found this article: http://support.microsoft.com/default.aspx?scid=kb;EN-US;248717 that says the following: ..........................
9
3732
by: Mario Rodriguez | last post by:
Hi people. I have a problem adding users to Win2003 active directory programatically. When I execute my app throws the following exception: .................The specified directory service attribute or value does not exist........... Exactly the same code works fine on my win2000 active directory. My app include the use of the extensionAtributes and I'm not sure if the extensionAttributes feature was removed from win2003 Active...
0
1478
by: Buddy Ackerman | last post by:
I have an application where the client wants AD integration. The application requires that the user accounts reside in the app's database. The application is a (.NET) webservices based app where the desktop client polls a webservice to return info to the user. The client wants to only manage accounts via the AD. So if they create a new AD user then the app should automatically create a user in the app database. This is not such a problem...
8
9071
by: CJM | last post by:
I'm trying to retrieve the users email address via ADSI in ASP. So far, I have the following code: Set oUser = GetObject("WinNT://domain/" & Request.Form("UID") & ",user") Response.Write oUser.EmailAddress But I get the following message: "The directory property cannot be found in the cache. "
3
3479
by: Mike P | last post by:
Hi, During loading of the Global.asax, I need to get back the "application name" that is configured in IIS. I have scoured the Http classes but there does not seem to be any way to get to it. I know in IIS 6.0, I could retrieve it through metabas.xml but I need this solution to work on Windows 2000, IIS 5.0 as well. Many Thanks in advance for your help
1
4755
by: Andrew | last post by:
Hey all, Working on revamping our Intranet here and making use of the LDPA, Active Directory, Directory Services, etc. that .Net provides. I am still fairly new on this subject, so the problem I have run into I am not sure how to fix, and really not sure what is causing it. Here's what is going on (test server - Windows 2003 Server): I have a page in a folder (under anonymous authentication in IIS6) that has a link on it that...
1
3895
by: tangus via DotNetMonster.com | last post by:
Hello all, I'm really struggling with getting some Active Directory code to work in ASP.NET. Can you please provide assistance? I am executing the following code: Dim enTry As DirectoryEntry = New DirectoryEntry("LDAP://domain") Dim mySearcher As New DirectorySearcher(enTry) Dim resEnt As SearchResult mySearcher.Filter = ("(objectClass=*)") mySearcher.SearchScope = SearchScope.Subtree
0
5415
by: Chung Leong | last post by:
In this brief tutorial I'll describe how you retrieve information from an Active Directory through the OLE-DB extension. While it is possible to use the LDAP extension to achieve the same goal, as you will see using Microsoft's OLE-DB provider is much easier. You will need to download and install the OLE-DB extension. Here's the location once again: http://sourceforge.net/project/showfiles.php?group_id=171247&package_id=198554. See my...
1
1920
by: rh | last post by:
Hi, I need to retrieve all usernames within an active directory security group (including sub-groups) into my C# application. Is there a relatively simple way of doing this? (I'm hoping for a simple ldap query but I feel I'm out of luck) Thanks, -rh
0
9647
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9492
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10360
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8988
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7510
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6744
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5532
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3668
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.