Solved

Can SQL pull user accounts from a domain server ?

Posted on 2004-10-07
11
292 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
  • 3
  • 2
  • 2
  • +1
11 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 12247211
0
 

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 142

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
 

Author Comment

by:Corvalion
ID: 12247524
yer sorry SQL 2000 and the domain is on another server
0
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.

 
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

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

Database tuning – How to start and what to tune. This question is frequently asked by many people, both online and offline. There is no hard and fast rule-of-thumb for performance tuning, however, before beginning the tuning process one should a…
In today’s complex data management environments, it is not unusual for UNIX servers to be dedicated to a particular department, purpose, or database.  As a result, a SAS® data analyst often works with multiple servers, each with its own data storage…
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

895 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

18 Experts available now in Live!

Get 1:1 Help Now