LDAP to get email address

  • Hello all,

    I want to use SQL server to connect to LDAP and return email address, first name, last name and all other details. Can anyone knows how to do this?

    Any help would be greatly appreciated.

    Thanks,

    Ramesh.

  • Give this a try - this worked for me on SQL 2005 instance. I'm assuming you're going to Active directory, but not sure...You also must have read permissions on Active Directory.

    EXEC sp_addlinkedserver 'ADSI', 'Active Directory Services 2.5', 'ADSDSOObject', 'adsdatasource'

    GO

    EXEC sp_addlinkedsrvlogin 'ADSI', 'true', 'Domain\userid', NULL, NULL

    GO

    Select *

    FROM OPENQUERY(ADSI, 'Select sn, givenName, mail

    FROM ''LDAP://SERVERNAME/ DC=domainpart1,DC=domainpart2,DC=local'' WHERE objectClass= ''user'' ORDER BY cn ')

  • how to get parameters for

    ''LDAP://SERVERNAME/ DC=domainpart1,DC=domainpart2,DC=local'' WHERE objectClass= ''user''

    i m having problem here now.

     

    Thanks,

    Ramesh.

  • Your network admin should know the LDAP server name.


    Urbis, an urban transformation company

  • what about other parameters?

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply