Error when Selecting AD attribute with a hyphen in the name
Good morning again all I have a problem accessing an attribute in AD via an LDAP open Query. The attribute has a hyphen inthe name and I get various errors depending on how I treat it: eg. SELECT 'OU=IT,OU=People' as OU ,sAMAccountName ,distinguishedName ,PhoneticDisplayName FROM OpenQuery(ADSI,'SELECT sAMAccountName ,distinguishedName ,[msDS-PhoneticDisplayName] as PhoneticDisplayName FROM''LDAP://OU=IT,OU=USERS2008,OU=ACCOUNTS,DC=x,DC=y,DC=z'' WHERE objectCategory=''Person'' and objectClass = ''user'' ' ) returns Msg 7321, Level 16, State 2, Line 2 An error occurred while preparing the query "SELECT sAMAccountName ...... for execution against OLE DB provider "ADSDSOObject" for linked server "ADSI". Without the square brackets, it searches for an sttribute name msDS. With the square brackets I get the above error. Does anyone have any ideas on how I can around this? Thanks.