You can create a view for data obtained from Active Directory. Be aware that only the view definition is stored in SQL Server, and not the actual result set. Therefore, you may get a different result when you invoke the view at a later time.
The following code sample shows how to create a view.
CREATE VIEW viewADUsers
AS
SELECT * FROM OpenQuery( ADSI,
'<LDAP://DC=Fabrikam,DC=com>;(&(objectCategory=Person)(objectClass=user));name, adspath, title;subtree')
Use the following code to invoke a view.
SELECT * from viewADUsers
Related topics
Creating a Heterogeneous Join between SQL Server and Active Directory
Source: Microsoft Learn / Windows Win32 documentation by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.
