CString to CComBSTR to use for IDirectorySearch
-
Im writing a program that searches an ActiveDirectory database and want the program to take a search argument like "moderator" through a dialog window and the program will search for everyone that is a moderator. So my search function takes a CString as a parameter But to use it in the search it must be a LPWSTR (pszSearchFilter). HRESULT ExecuteSearch(LPWSTR pszSearchFilter, LPWSTR* pAttributeNames, DWORD dwNumberAttributes, PADS_SEARCH_HANDLE phSearchHandle); I havetried to builda CString that looks like this: L"(&(objectClass=user)(title=moderator))"; And then it must be converted to LPWSTR or CComBSTR or whatever that works ... any ideas how ? Thanks in advance !
-
Im writing a program that searches an ActiveDirectory database and want the program to take a search argument like "moderator" through a dialog window and the program will search for everyone that is a moderator. So my search function takes a CString as a parameter But to use it in the search it must be a LPWSTR (pszSearchFilter). HRESULT ExecuteSearch(LPWSTR pszSearchFilter, LPWSTR* pAttributeNames, DWORD dwNumberAttributes, PADS_SEARCH_HANDLE phSearchHandle); I havetried to builda CString that looks like this: L"(&(objectClass=user)(title=moderator))"; And then it must be converted to LPWSTR or CComBSTR or whatever that works ... any ideas how ? Thanks in advance !
Try converting the CString into a _bstr_t CString searchParameter("the search string"); _bstr_t bstr(searchParameter); Mike
-
Im writing a program that searches an ActiveDirectory database and want the program to take a search argument like "moderator" through a dialog window and the program will search for everyone that is a moderator. So my search function takes a CString as a parameter But to use it in the search it must be a LPWSTR (pszSearchFilter). HRESULT ExecuteSearch(LPWSTR pszSearchFilter, LPWSTR* pAttributeNames, DWORD dwNumberAttributes, PADS_SEARCH_HANDLE phSearchHandle); I havetried to builda CString that looks like this: L"(&(objectClass=user)(title=moderator))"; And then it must be converted to LPWSTR or CComBSTR or whatever that works ... any ideas how ? Thanks in advance !
You should be able to do it like this...
CString str("Hack on!");
BSTR bstr = str.AllocSysString();CComBSTR bstrTemp;
bstrTemp.Attach(bstr);Hack on... :) Jonathan Craig www.mcw-tech.com
-
Im writing a program that searches an ActiveDirectory database and want the program to take a search argument like "moderator" through a dialog window and the program will search for everyone that is a moderator. So my search function takes a CString as a parameter But to use it in the search it must be a LPWSTR (pszSearchFilter). HRESULT ExecuteSearch(LPWSTR pszSearchFilter, LPWSTR* pAttributeNames, DWORD dwNumberAttributes, PADS_SEARCH_HANDLE phSearchHandle); I havetried to builda CString that looks like this: L"(&(objectClass=user)(title=moderator))"; And then it must be converted to LPWSTR or CComBSTR or whatever that works ... any ideas how ? Thanks in advance !