Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Sql server 2005 active directory users - distribution group

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

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 …
Last week, our Skyport webinar on “How to secure your Active Directory” (https://www.experts-exchange.com/videos/5810/Webinar-Is-Your-Active-Directory-as-Secure-as-You-Think.html?cid=Gene_Skyport) provided 218 attendees with a step-by-step guide for…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
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.

791 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