How to connect to AD from SQL server

Hi,

I need to connect to Active Directory in a stored procedure to try to verify if a user exists. Can you please help me with the code snippet to do the same? 

Thanks

July 28th, 2015 12:54am

Hi arvindmbh

you can connect active directory to sql server from open query command

you can read out here how to deal with AD and sql server here

https://msdn.microsoft.com/en-US/library/ms190803.aspx

Free Windows Admin Tool Kit Click here and download it now
July 28th, 2015 1:27am

You can gain access to Active Directory in order to verify the existence of User using OpenRowSet . this method is one time & ad-hoc method to access remote data using OLE DB

OPENROWSET ( 'provider_name' , { 'datasource' ; 'user_id' ; 'password' | 'provider_string' } , { [ catalog. ] [ schema. ] object | 'query' } )

 

SELECT * FROM OPENROWSET( 'AdsDsoObject' , 'User ID=user1;Password=pwd1;ADSI Flag=0x11;Page Size=10000', 'SELECT givenName,sn FROM ''LDAP://addevdc01/OU=Users,OU=account1,DC=dev,DC=net''') where sn like 'Mike'

 

Hope it will help!

/* Please Propose it as Answer if you found it is beneficial to solve your query */


July 28th, 2015 2:01am

Hello,

Other option is to use xp_logininfo (Transact-SQL) to verify an account or a Windows Group.

Free Windows Admin Tool Kit Click here and download it now
July 28th, 2015 2:21am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics