473,385 Members | 1,753 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Retrieving Active Directory Hierarchies through ASP.NET and C#

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_Department
----------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_Department
----------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 distinguishedName 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 1320

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

Similar topics

0
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...
9
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...
0
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...
8
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...
3
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...
1
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...
1
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 =...
0
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...
1
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.