Solved

Sql server 2005 active directory users - distribution group

Posted on 2010-08-19
3
504 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

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SQL Help 27 40
GPO Central Store 3 20
SQL Improvement  ( Speed) 14 26
Azure Active Directory Connect change from domain.local to domain.com 1 25
Disabling the Directory Sync Service Account in Office 365 will stop directory synchronization from working.
While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

813 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