Last active
June 9, 2023 16:47
-
-
Save skahwah/c2de4878fe04fbe0fff565e9c155cd81 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create a new ADSI linked server, where '@datasrc=' contains the name of the domain controller | |
EXEC master.dbo.sp_addlinkedserver | |
@server = N'linkADSI', | |
@srvproduct=N'Active Directory Service Interfaces', | |
@provider=N'ADSDSOObject', | |
@datasrc=N'DC01.KAWALABS.LOCAL'; | |
# Configure authentication to the ADSI linked server. | |
EXEC master.dbo.sp_addlinkedsrvlogin | |
@rmtsrvname=N'linkADSI', | |
@useself=N'False', | |
@locallogin=NULL, | |
@rmtuser=N'KAWALABS\mssql_svc', | |
@rmtpassword='Password123'; | |
# Test to see if the link has been created. | |
SELECT * FROM OPENQUERY( linkADSI, 'SELECT * from ''LDAP://kawalabs.local'' where name=''Administrator'' ') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment