SQL Server 2008 reads domain account information

Source: Internet
Author: User
Tags ldap

Reference: http://www.pawlowski.cz/2011/04/querying-active-directory-sql-server-t-sql/

1. Set up link server.

Use master

  Go

EXEC sp_addlinkedserver ' ADSI ', ' Active Directory Services 2.5 ', ' adsdsoobject ', ' Adsdatasource '

2.

exec sp_configure ' show advanced options ', 1
Reconfigure with override

exec sp_configure ' Ad Hoc distributed Queries ', 1
Reconfigure

3. Query domain account information:

SELECT * from OpenQuery (ADSI, ' SELECT * from ' ldap://dc=huanhua,dc=test ' WHERE objectcategory= ' user ')

SELECT * from OpenQuery (ADSI1, ' SELECT * from ' ldap://192.168.1.100/dc=huanhua,dc=test ' WHERE objectcategory= ' user ' ‘)

Query results

Actual domain account information:

Other:

SELECT * FROM
OpenQuery (ADSI1, ' SELECT cn,adspath from ' ldap://192.168.1.100/dc=huanhua,dc=test ' WHERE objectcategory= ' user ')

Note: If the prompt does not have permission, the linked database must be logged on with a domain account.

SQL Server 2008 reads domain account information

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.