0

I am looking for code to query the Global Address List (GAL) to obtain contacts email. I'm able to do this using VBA code. However, I was wondering if it's possible to do the same using SQL code. Also, I thinking about using SSIS package to pull over the data as well.

ccarpenter32
  • 1,058
  • 2
  • 9
  • 17
Green
  • 695
  • 2
  • 9
  • 21

1 Answers1

0

It may be something similar to:

SELECT sAMAccountName, name, mail AS email
FROM OPENQUERY(ADSI, 'SELECT sAMAccountName, name, mail FROM 
    ''LDAP://myServer/OU=myOU,DC=myDC1,DC=myDC2'' 
    WHERE objectCategory=''person'' AND objectClass = ''user'' '
)
Shawn
  • 4,758
  • 1
  • 20
  • 29