473,395 Members | 1,941 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,395 software developers and data experts.

Recursive Stored Procedure

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.1.1 Computers
1.1.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 store procedure 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 procedure or function in the context to return and create the AD Hierarchy.


Could anyone help with it?

Thank you very much for you attention!
Jul 18 '08 #1
3 2368
ck9663
2,878 Expert 2GB
I'd say use XML


-- CK
Jul 18 '08 #2
Hi,

Thank you for the answer!

I don't know how to approach it using XML.

Could you help me on how to start it?
Jul 18 '08 #3
Delerna
1,134 Expert 1GB
Here is a question similar to yours that you might find helpful.
Jul 18 '08 #4

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

Similar topics

3
by: Robert Song | last post by:
Hi all I am implementing a stored procedure which needs to recursively call itself until specific condition is reached, Could anyone give some advice about that? Thanks a lot Robert Song
4
by: Rodusa | last post by:
I am having problem to apply updates into this function below. I tried using cursor for updates, etc. but no success. Sql server keeps telling me that I cannot execute insert or update from inside...
2
by: Dino L. | last post by:
How can I run stored procedure (MSSQL) ?
5
by: purushneel | last post by:
Hi, I work primarily on Oracle databases. I am trying to convert a recursive stored procedure written in Oracle to DB2. Does DB2 UDB v8.2 (Windows/AIX) supports recursive stored procedures ??...
4
by: Henrik Juul | last post by:
How do I call my Stored Procedure recursively: CREATE PROCEDURE dbo.GetParentIONode ( @IONodeID int, @FullNodeAddress char(100) OUTPUT ) AS BEGIN
3
by: oregondba | last post by:
I have a database I have inherited (new job). I am trying to baseline the code and have done a DB2Look to get the code out of an existing db. The DB2Look produced a SP with the following form: ...
0
by: champ1979 | last post by:
I wrote an algorithm to get all the relatives of a person in a family tree. I'm basically getting all the users from the DB and am doing the recursive logic in code, so that there is only 1 call...
3
by: jzdoh | last post by:
I am trying to write a stored procedure that could create a table called tblManagerHierarchy. It is a table that contains recursive data. The data is coming from tblEmployee where it contains that...
1
by: bipinskulkarni | last post by:
How to write recursive stored procedure in mysql?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...

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.