I have a query written that works fine when I use almost any distinguishedName. But when I use one with a single quote, I get a com_error exception.
I've tried versions of the filter with both ' and '' and both throw the same error.
I've also used the search string (with the single ') in Softerra LDAP Browser and successfully run the query so I know it is well-formed.
Here's a minimal example of the code I'm running (name redacted by ■):
from pyad import adquery
q = adquery.ADQuery()
q.execute_query(base_dn = "OU=■■■■,DC=americas,DC=corpdir,DC=net",
where_clause = (
R"distinguishedName=CN=■'■■■■\, ■■■■■■■ (164),"
"OU=Users,OU=CVD,OU=■■■■,DC=americas,DC=corpdir,DC=net"
),
)
[x for x in q.get_results()]
And here's the error that it produces
---------------------------------------------------------------------------
com_error Traceback (most recent call last)
H:\AppData\Local\Temp/ipykernel_3572/3834525592.py in <module>
5 q.execute_query(base_dn = "OU=■■■■,DC=americas,DC=corpdir,DC=net",
6 where_clause = (
----> 7 R"distinguishedName=CN=■'■■■■\, ■■■■■■■ (164),"+
8 "OU=Users,OU=CVD,OU=■■■■,DC=americas,DC=corpdir,DC=net"
9 ),
C:\ProgramData\Anaconda3\lib\site-packages\pyad\adquery.py in execute_query(self, attributes, where_clause, type, base_dn, page_size, search_scope, options)
76
77 command.CommandText = query
---> 78 self.__rs, self.__rc = command.Execute()
79 self.__queried = True
80
~\AppData\Roaming\Python\Python37\site-packages\win32com\client\dynamic.py in Execute(self, RecordsAffected, Parameters, Options)
~\AppData\Roaming\Python\Python37\site-packages\win32com\client\dynamic.py in _ApplyTypes_(self, dispid, wFlags, retType, argTypes, user, resultCLSID, *args)
269
270 def _ApplyTypes_(self, dispid, wFlags, retType, argTypes, user, resultCLSID, *args):
--> 271 result = self._oleobj_.InvokeTypes(*(dispid, LCID, wFlags, retType, argTypes) + args)
272 return self._get_good_object_(result, user, resultCLSID)
273
com_error: (-2147352567, 'Exception occurred.', (0, 'Provider', 'One or more errors occurred during processing of command.', None, 1240640, -2147217900), None)
From what I can tell, I'm either not understanding how to use the library or there might be a bug?
I have a query written that works fine when I use almost any
distinguishedName. But when I use one with a single quote, I get acom_errorexception.I've tried versions of the filter with both
'and''and both throw the same error.I've also used the search string (with the single
') in Softerra LDAP Browser and successfully run the query so I know it is well-formed.Here's a minimal example of the code I'm running (name redacted by ■):
And here's the error that it produces
From what I can tell, I'm either not understanding how to use the library or there might be a bug?