Solved

Sql server 2005 active directory users - distribution group

Posted on 2010-08-19
3
492 Views
Last Modified: 2012-06-27
Hi All,
 
         I was able to pull the users from Active Directory into my sql server 2005 User table.
I followed http://blog.tech-cats.com/2007/09/querying-active-directory-through-sql.html

It successfully pulls user's generic information like  givenName ,sn ,displayName,  sAMAccountName,
telephoneNumber ,mobile , mail ,department,  physicalDeliveryOfficeName

The company I work for is distributed globally. Each country is located as a separate folder in active directory. When I pull user's into sql server table I would like to know which folder from active directory are they coming from in order for me to group users correctly based on country

Please help!!!
0
Comment
Question by:Hlobo
  • 2
3 Comments
 
LVL 10

Accepted Solution

by:
rscottvan earned 500 total points
ID: 33486114
You'll need to grab the Distinguished Name (DN) which includes the AD path to the account.

Technically, what you're calling "folders" in AD are actually Organizational Units (OUs.)  

 A DN looks like this:
CN=<user name>, OU= <"folder">, OU=<"folder">,DC=<domain>,DC=<domain>

You'll have to parse out the OUs.

For example, if my account name was scott, and the tree was like this:
mydomain.com
--north america
----usa
------arizona
--------phoenix
----------scott
My DN would be:
CN=Scott,CN=users,OU=phoenix,OU=arizona,OU=usa,OU=north america,DC=mydomain,DC=com
0
 

Author Comment

by:Hlobo
ID: 33502239
Awesome ..Thank you so much rscottvan!
0
 

Author Comment

by:Hlobo
ID: 33532194
Hello All,

       I would like sql server 2005 script to get Get a list of users in a Distribution group

how would i do this?

I followed http://blog.tech-cats.com/2007/09/querying-active-directory-through-sql.html

but now I want users belonging to a security/distribution group
0

Join & Write a Comment

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how the fundamental information of how to create a table.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now