K
K
Kvert0072014-02-26 15:38:47
LDAP
Kvert007, 2014-02-26 15:38:47

LDAP request encoding: how?

Hello, this is the problem. There is a code:

hr = pADsys->get_UserName(&bstr);
  if (hr!=S_OK)
  {
    string error= format_error(hr);
    LPSTR error1 = const_cast<char *>(error.c_str());
    PutInfotoFileLog(error1,"getDomainUserSAMAccountName:get_UserName",4);
    return ConvertStdStringToAnsiBSTR(error1);
  }//получаем полное имя пользователя в домене
  IADs *pUsr=NULL; //контейнер
 	USES_CONVERSION; //Макросы преобразования
  string strDesc = static_cast<CHAR*>(CW2A(bstr));//
  string LDAP="LDAP://";		//
  string path = LDAP + strDesc;
  wstring wstr( path.begin(), path.end() );	//
  LPCTSTR path2 = W2CT( wstr.c_str( ) );	//формирование корректного пути для создания объекта из AD и приведение типа std::string к LPCTSTR
  hr = ADsGetObject( path2, IID_IADs,(void**)&pUsr);

Everything works fine until Russian characters are found in the path, let's say the path is
LDAP://CN=Yuri Petrov,CN=ххххх,DC=ххх,DC=хх
Here an error occurs that the object was not found on the server. I think the problem is in the request encoding, but that's just a guess.
Please help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2014-02-26
@Rsa97

If AD is used, then the encoding must be Windows-1251

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question