Ask a questionAsk a question
 

AnswerEcDoConnectEx throw an exception

  • Friday, September 25, 2009 12:39 PMJacobHuang Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    I have create an RPC binding with the "ncacn_ip_tcp" and set the authentication with "RPC_C_AUTHN_WINNT",filled all the parameters in the EcDoConnectEx function,then call the EcDoConnectEx function,then system throw a exception dialog, promt :"Unhandled exception at 0x7c812afb in rcp3.exe: 0x000006B5: interface unknown". below is the code:

    {//begin
     RPC_STATUS status;
     unsigned short *StringBinding;
     RPC_BINDING_HANDLE BindingHandle;

     TCHAR* protocolSequence = L"ncacn_ip_tcp";
     TCHAR* serverDNS = L"some.corp.com";
     TCHAR* enePoint = L"135";

     TCHAR* objUuid = L"A4F1DB00-CA47-1067-B31F-00DD010662DA";

     status = RpcStringBindingCompose((RPC_WSTR)objUuid,  // Object UUID
      (RPC_WSTR)protocolSequence,           // Protocol sequence to use
      (RPC_WSTR)serverDNS, // Server DNS or Netbios Name
      (RPC_WSTR)enePoint,
      NULL,
      &StringBinding);
     // Error checking ommitted. If no error, we proceed below
     status = RpcBindingFromStringBinding(StringBinding, &BindingHandle);


     TCHAR* wPrnName = NULL;
     RpcMgmtInqServerPrincName( BindingHandle, RPC_C_AUTHN_WINNT, (RPC_WSTR*) &wPrnName);

     SEC_WINNT_AUTH_IDENTITY sec;
     sec.Domain = (unsigned short*)L"corp.com";            
     sec.DomainLength = 11;
     sec.Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE;
     sec.Password = (unsigned short *)L"myPwd";
     sec.PasswordLength = 8;
     sec.User = (unsigned short *)L"myuserName";
     sec.UserLength = 10;

     if(RpcBindingSetAuthInfo(BindingHandle,(RPC_WSTR)wPrnName,RPC_C_AUTHN_LEVEL_PKT_PRIVACY,RPC_C_AUTHN_WINNT,(RPC_AUTH_IDENTITY_HANDLE)&sec,RPC_C_AUTHN_NONE) != RPC_S_OK)
      cout<<"Set Auth Error!"<<endl;

     CXH pcxh = NULL;
     unsigned char* szUserDN = (unsigned char*)"/o=MS/ou=MS First/CN=Recipients/CN=someone";
     unsigned long ulFlags = 0x00000000;
     unsigned long ulConMod = emsmdb_hash((char*)szUserDN);
     unsigned long cbLimit = 0x00000000;
     unsigned long ulCpid = 0x000004E4; 
     unsigned long ulLcidString = 0x00000409; 
     unsigned long ulLcidSort = 0x00000409;  
     unsigned long ulIcxrLink = 0xFFFFFFFF;
     unsigned short usFCanConvertCodePages = 0x01;


     unsigned long cmsPollsMax;
     unsigned long cRetry;
     unsigned long cmsRetryDalay;
     unsigned short icxr;
     unsigned char szDNPrefix[512];
     unsigned char szDisplayName[512];

     memset(szDisplayName,0,512);
     memset(szDNPrefix,0,512);

     unsigned short rgwClientVersion[3];
     rgwClientVersion[0] = 0x000c;
     rgwClientVersion[1] = 0x183e;
     rgwClientVersion[2] = 0x03e8;

     unsigned short rgwServerVersion[3];
     unsigned short rgwBestVersion[3];

     unsigned long ulTimeStamp = 0;

     unsigned char* rgbAuxIn = NULL;  
     unsigned long cbAuxIn = 0x00000000; 

     unsigned char rgbAuxOut[0x1008];
     SMALL_RANGE_ULONG pcbAuxOut = 0x00001008; 

     long retValue;
    etValue = EcDoConnectEx(BindingHandle,
                                           &pcxh,szUserDN,
                                           ulFlags,ulConMod,
                                           cbLimit,ulCpid,
                                           ulLcidString,
                                           ulLcidSort,ulIcxrLink,
                                           usFCanConvertCodePages,
                                           &cmsPollsMax,&cRetry,
                                           &cmsRetryDalay,
                                           &icxr,(unsigned char**)&szDNPrefix,
                                           (unsigned char**)&szDisplayName,
                                           rgwClientVersion,rgwServerVersion,
                                           rgwBestVersion,&ulTimeStamp,
                                           rgbAuxIn,cbAuxIn,rgbAuxOut,&pcbAuxOut)


     RpcBindingFree(&BindingHandle);
     RpcStringFree(&StringBinding);
     return 0;
    }//end of the code


    Almost  all the parameter value is copy from the example of the exchange protocol document [MS-OXCRPC]4.1,all the server name and the username is sure to be right,and I compile the idl(in the [MS-OXCRPC]section 6)with the Visual Studio 2005,the code above is also in the enviroment with VS2005.

    Could anyone tell me why I can't receive a response from the server,rather than an annoying exception?thank you!

    • Edited byJacobHuang Saturday, September 26, 2009 6:32 AM
    •  

Answers

All Replies