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?
asked Sep 07, 2010 at 05:35 PM in Default
Hi all I have solved it. No idea how but by cutting various segments and running them separately then patching it back together it now runs.
answered Sep 07, 2010 at 10:49 PM