[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Sql server 2005 active directory users - distribution group

Posted on 2010-08-19
3
Medium Priority
?
535 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
[X]
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
  • 2
3 Comments
 
LVL 10

Accepted Solution

by:
rscottvan earned 2000 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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

In the absence of a fully-fledged GPO Management product like AGPM, the script in this article will provide you with a simple way to watch the domain (or a select OU) for GPOs changes and automatically take backups when policies are added, removed o…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Suggested Courses

649 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