Solved

Can SQL pull user accounts from a domain server ?

Posted on 2004-10-07
11
328 Views
Last Modified: 2008-02-01
If so how (points only awarded if possible)

I want to pul of account names, usernames and groups in (only)

thanks

Corv
0
Comment
Question by:Corvalion
[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
  • 3
  • 2
  • 2
  • +1
11 Comments
 

Author Comment

by:Corvalion
ID: 12247270
not quite what i was looking for was, I want to import user accounts from the domain with usergroups
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 12247314
Did the above links already give you ideas, have you problems using them or what?
Are you using SQL Server or not, if not specify?
WE ARE NOT SITTING IN FRONT OF YOUR DESK, you have to tell use something...
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Corvalion
ID: 12247524
yer sorry SQL 2000 and the domain is on another server
0
 
LVL 9

Expert Comment

by:konektor
ID: 12247626
i'm not sure what do you want ...
do u want each user in operating system should be assosicated one user in database ? the best way seem to be create user identified by external - u do need to enter password while logging in, but u can connect into oracle only when you are connected into operating system under the same user under which db user was created - u r identified by external user (operating system user)

if u ant to store the same user/role structure in oracle as u have in operating system look for some "identity manager" software and adapter for oracle for it
0
 

Author Comment

by:Corvalion
ID: 12247985
I am trying to get the user account details from an NT domain server so i can inport the accounts when they are created for normal NT use and exchange use. other than that I cant explain any better which made it had to look for.
0
 
LVL 9

Accepted Solution

by:
rherguth earned 125 total points
ID: 12253216
You can pull logins and groups through Active Directory using a linked server in SQL Server 2000.  Unfortunately, you cannot pull the users names that are in a particular group because the datatype returned by ADSI is not supported by SQL Server.

-- Link the server
EXEC sp_addlinkedserver 'ADSI', 'Active Directory Services 2.5', 'ADSDSOObject', 'adsdatasource'
GO
-- Set the password
EXEC sp_addlinkedsrvlogin 'ADSI', false, 'sa', 'CN=Administrator,OU=Users - Admins,DC=myserver,DC=mydomain,DC=com', 'pwd'
GO

Sample query grabs groups from domain
SELECT name
FROM OpenQuery(ADSI, '
      <GC://OU=Users,DC=myserver,DC=mydomain,DC=com>;(&(objectCategory=group)(name=*));name,adsPath'
)

sample Query grabs data from exchange server:
SELECT
      DomainUsers.displayName [DisplayName]
      , DomainUsers.title [Title]
      , DomainUsers.mail [EMail]
      , DomainUsers.TelephoneNumber [Phone]
      , DomainUsers.facsimileTelephoneNumber [FAX]
      , DomainUsers.sAMAccountName [DomainAccount]
      , DomainUsers.mailnickname [ExchangeAccount]
      , DomainUsers.homephone [WebURL]
      , DomainUsers.pager [Pager]
      , DomainUsers.mobile [MobilePhone]
      , DomainUsers.postalcode [ZIPCode]
--      , DomainUsers.primarygroupid
--      , DomainUsers.adsPath
--      , DomainUsers.distinguishedName [DN]
--      , DomainUsers.cn [CN]
--      , DomainUsers.sn [LastName]
--      , DomainUsers.givenName [FirstName]
--      , DomainUsers.[name] [ADS Name]
--      , DomainUsers.thumbnailPhoto
FROM
      OpenQuery (ADSI,
            '<LDAP://DC=myserver,DC=mydomain,DC=com>;(&(objectCategory=person)(objectClass=user));
            sn, givenName, name, displayName, cn, title, TelephoneNumber, facsimileTelephoneNumber
            , mailnickname, distinguishedName, homephone, pager, mobile, postalcode
            , sAMAccountName, mail, adsPath, primarygroupid, thumbnailPhoto;
            subtree'
      ) [DomainUsers]
WHERE DomainUsers.sn IS NOT NULL
      -- DisplayName must have a comma
      And IsNull(CHARINDEX(',', DomainUsers.displayName), 0) > 0
ORDER BY
      DomainUsers.sn
      ,DomainUsers.givenName

-- drop the linked server (Optional but recommended, you could just leave it available)
EXEC sp_droplinkedsrvlogin 'ADSI', 'sa'
EXEC sp_dropserver 'ADSI'
GO
0
 
LVL 9

Expert Comment

by:rherguth
ID: 12718297
I like my answer :)
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

As technology users and professionals, we’re always learning. Our universal interest in advancing our knowledge of the trade is unmatched by most industries. It’s a curiosity that makes sense, given the climate of change. Within that, there lies a…
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

623 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