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
Technology Tips and News
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
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
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 */
Hello,
Other option is to use xp_logininfo (Transact-SQL) to verify an account or a Windows Group.