none
[MS-OXCRPC] how to designate a RPC binding handle with RPC_C_AUTHN_WINNT RRS feed

  • Question

  • In the question "EcDoConnectEx throw an exception",when I call the interface EcDoConnectEx, the server throw a 1717(the interface is unknown) exception.

    I have captured the data packets when the Outlook 2003 connected to the Exchange server and my program conected to the exchange server,and compared them.
    I have found that on the [bind] and [bind_ack] data packets,which is the fourth packet,after 3 tcp/ip packet. The Outlook Info is Bind:called id:1 uuid:EPM,however,my program Info is Bind:called id:1 uuid:Mgmt, I guess it is the reason that my program failed, because the authentication method I designate may be incorrect.

    In the document [MS-OXCRPC] said:"Client creates an RPC binding handle to the server with the "ncacn_ip_tcp" protocol sequence and the RPC_C_AUTHN_WINNT authentication method."

    I am a Novice in this area, could anyone tell me how to designate the authentication method, along with which interfaces to call is better. To generate data packet which is identical to the Outlook's.
    Thank you in advanced!


     The code I used to set the authentication is below:
    {// code bigen
    //after call to RpcStringBindingCompose() and RpcBindingFromStringBinding()

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

     SEC_WINNT_AUTH_IDENTITY sec;
     sec.Domain = (unsigned short*)L"corp.com";   //domain
     sec.DomainLength = 11;
     sec.Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE;
     sec.Password = (unsigned short *)L"_88hhuu";   //pawword
     sec.PasswordLength = 8;
     sec.User = (unsigned short *)L"jacob";    //user name
     sec.UserLength = 10;

    RpcBindingSetAuthInfo(BindingHandle,
                                     (RPC_WSTR)wPrnName,
                                     RPC_C_AUTHN_LEVEL_PKT_PRIVACY,
                                     RPC_C_AUTHN_WINNT, 
                                     (RPC_AUTH_IDENTITY_HANDLE)&sec,
                                     RPC_C_AUTHN_NONE);  
    }// code end

    //the deveploment tool is Visual Studio 2005, WinXP SP3

    Tuesday, September 29, 2009 6:50 AM

Answers

  • Hi Jacob,

    Here is a sample I that got working.   I have successfully tried this against Exchange Server 2007 and 2010.
    // stdafx.h : include file for standard system include files,
    // or project specific include files that are used frequently, but
    // are changed infrequently
    //
    
    #pragma once
    
    #include "targetver.h"
    #include <tchar.h>
    #include <rpc.h>
    #include "client_h.h"
    #include "hash.h"
    

    And the main code:
    #include "stdafx.h"
    
    class ExchangeRpc
    {
    public:
    	ExchangeRpc() 
    	{
    		m_hBind = NULL;
    		m_cxh = NULL;
    		m_swai = new SEC_WINNT_AUTH_IDENTITY;
    		memset(m_swai, 0, sizeof(SEC_WINNT_AUTH_IDENTITY));
    	};
    	~ExchangeRpc()
    	{
    		delete m_swai;
    	}
    	void AuthIdentity(const wchar_t * domain, const wchar_t * username, const wchar_t * password);
    	unsigned long Bind(const wchar_t * server);
    	unsigned long Connect(const char * userDN);
    	unsigned long Disconnect();
    	unsigned long UnBind();
    private:
    	RPC_BINDING_HANDLE m_hBind;
    	CXH m_cxh;
    	SEC_WINNT_AUTH_IDENTITY * m_swai;
    } ;
    
    int _tmain(int argc, _TCHAR* argv[])
    {
    	unsigned long status = 0;
    	const wchar_t * domain = L"jokull";
    	const wchar_t * username = L"iceman";
    	const wchar_t * password = L"123!@#";
    	const wchar_t * server = L"vatna";
    	const char * userDN = "/o=jokull/ou=eu/cn=Recipients/cn=5551212";
    
    	ExchangeRpc e;
    	e.AuthIdentity(domain, username, password);
    
    	status = e.Bind(server);
    	if (status == 0)
    	{
    		status = e.Connect(userDN);
    		if (status == 0)
    		{
    			e.Disconnect();
    		}
    		e.UnBind();
    	}
    	return status;
    }
    
    // Global routines
    unsigned long HandleException(RPC_STATUS status);
    unsigned long EndPoint(RPC_WSTR server, RPC_WSTR uuid, RPC_WSTR * pEndpoint, RPC_WSTR * pSequence);
    
    void ExchangeRpc::AuthIdentity(const wchar_t * domain, const wchar_t * username, const wchar_t * password)
    {
    	if (domain && *domain)
    	{
    		m_swai->Domain = (unsigned short *)_tcsdup(domain);
    		m_swai->DomainLength = (unsigned long)_tcslen(domain);
    	}
    	if (username && *username)
    	{
    		m_swai->User = (unsigned short *)_tcsdup(username);
    		m_swai->UserLength = (unsigned long)_tcslen(username);
    	}	
    	if (password && *password)
    	{
    		m_swai->Password = (unsigned short *)_tcsdup(password);
    		m_swai->PasswordLength = (unsigned long)_tcslen(password);
    	}
    	m_swai->Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE;
    } // ExchangeRpc::AuthIdentity
    
    unsigned long ExchangeRpc::Bind(const wchar_t * server)
    {
    	unsigned long status = 0;
    	RPC_WSTR sequence = NULL;
    	RPC_WSTR endpoint = NULL;
    	RPC_WSTR uuid = (RPC_WSTR)L"A4F1DB00-CA47-1067-B31F-00DD010662DA";
    
    	status = EndPoint((RPC_WSTR)server, uuid, &endpoint, &sequence);
    	if (status == 0)
    	{
    		RPC_BINDING_HANDLE hReturnBinding = NULL;
    		RPC_WSTR binding = NULL;
    
    		status = RpcStringBindingCompose(uuid, sequence, (RPC_WSTR)server, endpoint, NULL, &binding);
    		if (status == 0)
    		{
    			status = RpcBindingFromStringBinding( binding, &m_hBind);
    			if (status == 0)
    			{
    				status = RpcEpResolveBinding(m_hBind, emsmdb_v0_81_c_ifspec);
    				if (status == 0)
    				{
    					status = RpcBindingSetAuthInfoEx(m_hBind,
    													NULL, // server principal name
    													RPC_C_AUTHN_LEVEL_PKT_PRIVACY, // authentication level
    													RPC_C_AUTHN_WINNT,	// authentication service
    													m_swai,	// authorization Identity
    													0,		// authorization service
    													NULL);	// quality of service
    				}
    			}
    		}
    		if (binding)
    		{
    			RpcStringFree(&binding);
    		}
    	}
    	if (endpoint)
    	{
    		delete endpoint;
    	}
    	if (sequence)
    	{
    		delete sequence;
    	}
    	return status;
    }  // ExchangeRpc::Bind
    
    unsigned long ExchangeRpc::Connect(const char * userDN)
    {
    	unsigned long status = 0;
    	unsigned long ulFlags = 0x00000000;
    	unsigned long ulConMod = Hash(userDN);
    	unsigned long cbLimit = 0;
    	unsigned long ulCpid = 0x000004E4; 
    	unsigned long ulLcidString = 0x00000409; 
    	unsigned long ulLcidSort = 0x00000409; 
    	unsigned long ulIcxrLink = 0xFFFFFFFF;
    	unsigned short usFCanConvertCodePages = 0x01;
    
    	unsigned long cmsPollsMax = 0;
    	unsigned long cRetry = 0;
    	unsigned long cmsRetryDelay = 0;
    	unsigned short iCxr = 0;
    
    	unsigned char * pszDNPrefix = NULL;
    	unsigned char * pszDisplayName = NULL;
    
    	unsigned short rgwClientVersion[3];
    	unsigned short rgwServerVersion[3];
    	unsigned short rgwBestVersion[3];
    
    	rgwClientVersion[0] = 0x000c;
    	rgwClientVersion[1] = 0x183e;
    	rgwClientVersion[2] = 0x03e8;
    
    	memset(rgwServerVersion, 0, sizeof(rgwServerVersion));
    	memset(rgwBestVersion, 0, sizeof(rgwBestVersion));
    
    	unsigned long ulTimeStamp = 0;
    
    	unsigned char * pbAuxIn = NULL;
    	unsigned long cbAuxIn = 0;
    
    	unsigned char rgbAuxOut[0x1008];
    	unsigned long cbAuxOut = 0x1008;
    
    	memset(rgbAuxOut, 0, sizeof(rgbAuxOut));
    
    	RpcTryExcept 
    	{
    		status = ::EcDoConnectEx(
    			m_hBind,		//[in]
    			&m_cxh,		//[out]
    			(unsigned char * )userDN, //[in]
    			ulFlags,	//[in]
    			ulConMod,	//[in]
    			cbLimit,	//[in] cbLimit
    			ulCpid,		//[in] ulCpid
    			ulLcidString,	//[in]
    			ulLcidSort,		//[in]
    			ulIcxrLink,		//[in]
    			usFCanConvertCodePages,	//[in]
    			&cmsPollsMax,	//[out]
    			&cRetry,		//[out]
    			&cmsRetryDelay, //[out]
    			&iCxr,			//[out]
    			&pszDNPrefix,	//[out]
    			&pszDisplayName,//[out]
    			rgwClientVersion,//[in]
    			rgwServerVersion,//[out]
    			rgwBestVersion,	//[out]
    			&ulTimeStamp,	//[in,out]
    			pbAuxIn,	//[in]
    			cbAuxIn,	//[in]
    			rgbAuxOut,	//[out]
    			&cbAuxOut	//[in,out]
    			);
    	}
    	RpcExcept( ::HandleException(::RpcExceptionCode()) )
    	{
    		status = ::RpcExceptionCode();
    	} 
    	RpcEndExcept;
    
    	return status;
    }  // ExchangeRpc::Connect
    unsigned long ExchangeRpc::Disconnect()
    {
    	unsigned long status = 0;
    
    	RpcTryExcept 
    	{
    		status = ::EcDoDisconnect(&m_cxh);
    	}
    	RpcExcept( ::HandleException(RpcExceptionCode()) )
    	{
    		status = ::RpcExceptionCode();
    	} 
    	RpcEndExcept;
    
    	return status;
    } // ExchangeRpc::Disconnect
    unsigned long ExchangeRpc::UnBind()
    {
    	return ::RpcBindingFree(&m_hBind);
    } // ExchangeRpc::UnBind
    
    unsigned long EndPoint(RPC_WSTR server, RPC_WSTR uuid, RPC_WSTR * pEndpoint, RPC_WSTR * pSequence)
    {
    	const wchar_t * DefaultProtSeq = L"ncacn_ip_tcp";
    	unsigned long status = 0;
    	RPC_WSTR binding = NULL;
    
    	status = RpcStringBindingCompose(NULL, (RPC_WSTR) DefaultProtSeq, server, NULL, NULL, &binding);
    
    	if (status == 0)
    	{
    		RPC_BINDING_HANDLE m_hBindEndPoint = NULL;
    
    		status = RpcBindingFromStringBinding(binding, &m_hBindEndPoint);
    		if (status == 0)
    		{
    			RPC_IF_ID ifId;
    
    			status = UuidFromString(uuid,&ifId.Uuid);
    			if (status == 0)
    			{
    				RPC_EP_INQ_HANDLE inquiryContext;
    
    				status = RpcMgmtEpEltInqBegin(m_hBindEndPoint, RPC_C_EP_MATCH_BY_IF, &ifId, RPC_C_VERS_ALL,NULL, &inquiryContext);
    				if (status == 0)
    				{
    					RPC_BINDING_HANDLE bindingTmp = NULL;
    					RPC_WSTR stringTmp = NULL;
    					RPC_WSTR protocolSeq = NULL;
    					RPC_WSTR endPoint = NULL;
    
    					status = RpcMgmtEpEltInqNext(inquiryContext, &ifId, &bindingTmp, NULL, NULL);
    					while (status == 0)
    					{
    						status = RpcBindingToStringBinding(bindingTmp, &stringTmp);
    						if ((status == 0) && (_tcsstr((const wchar_t *)stringTmp, DefaultProtSeq) != NULL))
    						{
    							status = RpcStringBindingParse(stringTmp, NULL, &protocolSeq, NULL, &endPoint, NULL);
    							if (status == 0)
    							{
    								rsize_t size = wcslen(DefaultProtSeq)+ 1;
    								*pSequence = (RPC_WSTR) new wchar_t[size];
    								wcscpy_s((wchar_t *)*pSequence, size, DefaultProtSeq);
    
    								size = wcslen((const wchar_t *)endPoint) + 1;
    								*pEndpoint = (RPC_WSTR) new wchar_t[size];
    								wcscpy_s((wchar_t *) *pEndpoint, size,(const wchar_t *)endPoint);
    
    								break;
    							}
    						}
    						status = RpcMgmtEpEltInqNext(inquiryContext, &ifId, &bindingTmp, NULL, NULL);
    					} // while (status == 0)
    					if (stringTmp)
    					{
    						RpcStringFree(&stringTmp);
    					}
    					if (protocolSeq)
    					{
    						RpcStringFree(&protocolSeq);
    					}
    					if (endPoint)
    					{
    						RpcStringFree(&endPoint);
    					}
    				} // RpcMgmtEpEltInqBegin == 0
    			} // UuidFromString == 0
    		} // RpcBindingFromStringBinding == 0
    		if (m_hBindEndPoint)
    		{
    			RpcBindingFree (&m_hBindEndPoint);
    		}
    	} // RpcStringBindingCompose == 0
    	if (binding)
    	{
    		RpcStringFree(&binding);
    	}
    	return status;
    } // EndPoint
    unsigned long HandleException(RPC_STATUS status)
    {
    	if ((status & 0xc0000000) == 0xc0000000)
    		return EXCEPTION_CONTINUE_SEARCH;
    	else
    		return EXCEPTION_EXECUTE_HANDLER;
    }
    void __RPC_FAR * __RPC_API midl_user_allocate(size_t len)
    {
    	return(new(unsigned char [len]));
    }
    void  __RPC_API midl_user_free(void __RPC_FAR * ptr)
    {
    	delete(ptr);
    }
    





    Developer Consultant
    Monday, October 12, 2009 9:58 PM
    Moderator

All replies

  • Hi Jacob,

    Thank you for your question.

    Someone from my team will be contacting you shortly.

    Regards,

    SEBASTIAN CANEVARI - MSFT Senior SEE Protocol Documentation Team
    Tuesday, September 29, 2009 1:10 PM
  • Hi Jacob,

    Let me add this to the sample code today that I have been developing.    I got the sample code working last night based your other question. 

    Developer Consultant
    Tuesday, September 29, 2009 3:51 PM
    Moderator
  • Hi Tom,
    Would you please share your sample code ,my email is csjmhuang@qq.com , thank you in advanced.
    Tuesday, September 29, 2009 4:16 PM
  • Hi Jacob,

    Here is a sample I that got working.   I have successfully tried this against Exchange Server 2007 and 2010.
    // stdafx.h : include file for standard system include files,
    // or project specific include files that are used frequently, but
    // are changed infrequently
    //
    
    #pragma once
    
    #include "targetver.h"
    #include <tchar.h>
    #include <rpc.h>
    #include "client_h.h"
    #include "hash.h"
    

    And the main code:
    #include "stdafx.h"
    
    class ExchangeRpc
    {
    public:
    	ExchangeRpc() 
    	{
    		m_hBind = NULL;
    		m_cxh = NULL;
    		m_swai = new SEC_WINNT_AUTH_IDENTITY;
    		memset(m_swai, 0, sizeof(SEC_WINNT_AUTH_IDENTITY));
    	};
    	~ExchangeRpc()
    	{
    		delete m_swai;
    	}
    	void AuthIdentity(const wchar_t * domain, const wchar_t * username, const wchar_t * password);
    	unsigned long Bind(const wchar_t * server);
    	unsigned long Connect(const char * userDN);
    	unsigned long Disconnect();
    	unsigned long UnBind();
    private:
    	RPC_BINDING_HANDLE m_hBind;
    	CXH m_cxh;
    	SEC_WINNT_AUTH_IDENTITY * m_swai;
    } ;
    
    int _tmain(int argc, _TCHAR* argv[])
    {
    	unsigned long status = 0;
    	const wchar_t * domain = L"jokull";
    	const wchar_t * username = L"iceman";
    	const wchar_t * password = L"123!@#";
    	const wchar_t * server = L"vatna";
    	const char * userDN = "/o=jokull/ou=eu/cn=Recipients/cn=5551212";
    
    	ExchangeRpc e;
    	e.AuthIdentity(domain, username, password);
    
    	status = e.Bind(server);
    	if (status == 0)
    	{
    		status = e.Connect(userDN);
    		if (status == 0)
    		{
    			e.Disconnect();
    		}
    		e.UnBind();
    	}
    	return status;
    }
    
    // Global routines
    unsigned long HandleException(RPC_STATUS status);
    unsigned long EndPoint(RPC_WSTR server, RPC_WSTR uuid, RPC_WSTR * pEndpoint, RPC_WSTR * pSequence);
    
    void ExchangeRpc::AuthIdentity(const wchar_t * domain, const wchar_t * username, const wchar_t * password)
    {
    	if (domain && *domain)
    	{
    		m_swai->Domain = (unsigned short *)_tcsdup(domain);
    		m_swai->DomainLength = (unsigned long)_tcslen(domain);
    	}
    	if (username && *username)
    	{
    		m_swai->User = (unsigned short *)_tcsdup(username);
    		m_swai->UserLength = (unsigned long)_tcslen(username);
    	}	
    	if (password && *password)
    	{
    		m_swai->Password = (unsigned short *)_tcsdup(password);
    		m_swai->PasswordLength = (unsigned long)_tcslen(password);
    	}
    	m_swai->Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE;
    } // ExchangeRpc::AuthIdentity
    
    unsigned long ExchangeRpc::Bind(const wchar_t * server)
    {
    	unsigned long status = 0;
    	RPC_WSTR sequence = NULL;
    	RPC_WSTR endpoint = NULL;
    	RPC_WSTR uuid = (RPC_WSTR)L"A4F1DB00-CA47-1067-B31F-00DD010662DA";
    
    	status = EndPoint((RPC_WSTR)server, uuid, &endpoint, &sequence);
    	if (status == 0)
    	{
    		RPC_BINDING_HANDLE hReturnBinding = NULL;
    		RPC_WSTR binding = NULL;
    
    		status = RpcStringBindingCompose(uuid, sequence, (RPC_WSTR)server, endpoint, NULL, &binding);
    		if (status == 0)
    		{
    			status = RpcBindingFromStringBinding( binding, &m_hBind);
    			if (status == 0)
    			{
    				status = RpcEpResolveBinding(m_hBind, emsmdb_v0_81_c_ifspec);
    				if (status == 0)
    				{
    					status = RpcBindingSetAuthInfoEx(m_hBind,
    													NULL, // server principal name
    													RPC_C_AUTHN_LEVEL_PKT_PRIVACY, // authentication level
    													RPC_C_AUTHN_WINNT,	// authentication service
    													m_swai,	// authorization Identity
    													0,		// authorization service
    													NULL);	// quality of service
    				}
    			}
    		}
    		if (binding)
    		{
    			RpcStringFree(&binding);
    		}
    	}
    	if (endpoint)
    	{
    		delete endpoint;
    	}
    	if (sequence)
    	{
    		delete sequence;
    	}
    	return status;
    }  // ExchangeRpc::Bind
    
    unsigned long ExchangeRpc::Connect(const char * userDN)
    {
    	unsigned long status = 0;
    	unsigned long ulFlags = 0x00000000;
    	unsigned long ulConMod = Hash(userDN);
    	unsigned long cbLimit = 0;
    	unsigned long ulCpid = 0x000004E4; 
    	unsigned long ulLcidString = 0x00000409; 
    	unsigned long ulLcidSort = 0x00000409; 
    	unsigned long ulIcxrLink = 0xFFFFFFFF;
    	unsigned short usFCanConvertCodePages = 0x01;
    
    	unsigned long cmsPollsMax = 0;
    	unsigned long cRetry = 0;
    	unsigned long cmsRetryDelay = 0;
    	unsigned short iCxr = 0;
    
    	unsigned char * pszDNPrefix = NULL;
    	unsigned char * pszDisplayName = NULL;
    
    	unsigned short rgwClientVersion[3];
    	unsigned short rgwServerVersion[3];
    	unsigned short rgwBestVersion[3];
    
    	rgwClientVersion[0] = 0x000c;
    	rgwClientVersion[1] = 0x183e;
    	rgwClientVersion[2] = 0x03e8;
    
    	memset(rgwServerVersion, 0, sizeof(rgwServerVersion));
    	memset(rgwBestVersion, 0, sizeof(rgwBestVersion));
    
    	unsigned long ulTimeStamp = 0;
    
    	unsigned char * pbAuxIn = NULL;
    	unsigned long cbAuxIn = 0;
    
    	unsigned char rgbAuxOut[0x1008];
    	unsigned long cbAuxOut = 0x1008;
    
    	memset(rgbAuxOut, 0, sizeof(rgbAuxOut));
    
    	RpcTryExcept 
    	{
    		status = ::EcDoConnectEx(
    			m_hBind,		//[in]
    			&m_cxh,		//[out]
    			(unsigned char * )userDN, //[in]
    			ulFlags,	//[in]
    			ulConMod,	//[in]
    			cbLimit,	//[in] cbLimit
    			ulCpid,		//[in] ulCpid
    			ulLcidString,	//[in]
    			ulLcidSort,		//[in]
    			ulIcxrLink,		//[in]
    			usFCanConvertCodePages,	//[in]
    			&cmsPollsMax,	//[out]
    			&cRetry,		//[out]
    			&cmsRetryDelay, //[out]
    			&iCxr,			//[out]
    			&pszDNPrefix,	//[out]
    			&pszDisplayName,//[out]
    			rgwClientVersion,//[in]
    			rgwServerVersion,//[out]
    			rgwBestVersion,	//[out]
    			&ulTimeStamp,	//[in,out]
    			pbAuxIn,	//[in]
    			cbAuxIn,	//[in]
    			rgbAuxOut,	//[out]
    			&cbAuxOut	//[in,out]
    			);
    	}
    	RpcExcept( ::HandleException(::RpcExceptionCode()) )
    	{
    		status = ::RpcExceptionCode();
    	} 
    	RpcEndExcept;
    
    	return status;
    }  // ExchangeRpc::Connect
    unsigned long ExchangeRpc::Disconnect()
    {
    	unsigned long status = 0;
    
    	RpcTryExcept 
    	{
    		status = ::EcDoDisconnect(&m_cxh);
    	}
    	RpcExcept( ::HandleException(RpcExceptionCode()) )
    	{
    		status = ::RpcExceptionCode();
    	} 
    	RpcEndExcept;
    
    	return status;
    } // ExchangeRpc::Disconnect
    unsigned long ExchangeRpc::UnBind()
    {
    	return ::RpcBindingFree(&m_hBind);
    } // ExchangeRpc::UnBind
    
    unsigned long EndPoint(RPC_WSTR server, RPC_WSTR uuid, RPC_WSTR * pEndpoint, RPC_WSTR * pSequence)
    {
    	const wchar_t * DefaultProtSeq = L"ncacn_ip_tcp";
    	unsigned long status = 0;
    	RPC_WSTR binding = NULL;
    
    	status = RpcStringBindingCompose(NULL, (RPC_WSTR) DefaultProtSeq, server, NULL, NULL, &binding);
    
    	if (status == 0)
    	{
    		RPC_BINDING_HANDLE m_hBindEndPoint = NULL;
    
    		status = RpcBindingFromStringBinding(binding, &m_hBindEndPoint);
    		if (status == 0)
    		{
    			RPC_IF_ID ifId;
    
    			status = UuidFromString(uuid,&ifId.Uuid);
    			if (status == 0)
    			{
    				RPC_EP_INQ_HANDLE inquiryContext;
    
    				status = RpcMgmtEpEltInqBegin(m_hBindEndPoint, RPC_C_EP_MATCH_BY_IF, &ifId, RPC_C_VERS_ALL,NULL, &inquiryContext);
    				if (status == 0)
    				{
    					RPC_BINDING_HANDLE bindingTmp = NULL;
    					RPC_WSTR stringTmp = NULL;
    					RPC_WSTR protocolSeq = NULL;
    					RPC_WSTR endPoint = NULL;
    
    					status = RpcMgmtEpEltInqNext(inquiryContext, &ifId, &bindingTmp, NULL, NULL);
    					while (status == 0)
    					{
    						status = RpcBindingToStringBinding(bindingTmp, &stringTmp);
    						if ((status == 0) && (_tcsstr((const wchar_t *)stringTmp, DefaultProtSeq) != NULL))
    						{
    							status = RpcStringBindingParse(stringTmp, NULL, &protocolSeq, NULL, &endPoint, NULL);
    							if (status == 0)
    							{
    								rsize_t size = wcslen(DefaultProtSeq)+ 1;
    								*pSequence = (RPC_WSTR) new wchar_t[size];
    								wcscpy_s((wchar_t *)*pSequence, size, DefaultProtSeq);
    
    								size = wcslen((const wchar_t *)endPoint) + 1;
    								*pEndpoint = (RPC_WSTR) new wchar_t[size];
    								wcscpy_s((wchar_t *) *pEndpoint, size,(const wchar_t *)endPoint);
    
    								break;
    							}
    						}
    						status = RpcMgmtEpEltInqNext(inquiryContext, &ifId, &bindingTmp, NULL, NULL);
    					} // while (status == 0)
    					if (stringTmp)
    					{
    						RpcStringFree(&stringTmp);
    					}
    					if (protocolSeq)
    					{
    						RpcStringFree(&protocolSeq);
    					}
    					if (endPoint)
    					{
    						RpcStringFree(&endPoint);
    					}
    				} // RpcMgmtEpEltInqBegin == 0
    			} // UuidFromString == 0
    		} // RpcBindingFromStringBinding == 0
    		if (m_hBindEndPoint)
    		{
    			RpcBindingFree (&m_hBindEndPoint);
    		}
    	} // RpcStringBindingCompose == 0
    	if (binding)
    	{
    		RpcStringFree(&binding);
    	}
    	return status;
    } // EndPoint
    unsigned long HandleException(RPC_STATUS status)
    {
    	if ((status & 0xc0000000) == 0xc0000000)
    		return EXCEPTION_CONTINUE_SEARCH;
    	else
    		return EXCEPTION_EXECUTE_HANDLER;
    }
    void __RPC_FAR * __RPC_API midl_user_allocate(size_t len)
    {
    	return(new(unsigned char [len]));
    }
    void  __RPC_API midl_user_free(void __RPC_FAR * ptr)
    {
    	delete(ptr);
    }
    





    Developer Consultant
    Monday, October 12, 2009 9:58 PM
    Moderator
  • Thank you for your help!
    It did give me much help !
    :-)
    Tuesday, October 13, 2009 1:40 AM