CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2013
    Posts
    30

    access denied in client

    I followed the MSDN tutorial on RPC programs:
    http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx

    but when i run the client i get access denied.
    Code:
    void main()
    {
        RPC_STATUS status;
        unsigned char * pszUuid             = NULL;
        unsigned char * pszProtocolSequence = (unsigned char *)"ncacn_ip_tcp";
        unsigned char * pszNetworkAddress   = (unsigned char *)"127.0.0.1";
        unsigned char * pszEndpoint         = (unsigned char *)"2048";
        unsigned char * pszOptions          = NULL;
        unsigned char * pszStringBinding    = NULL;
        unsigned char * pszString           = (unsigned char *)"hello, world";
        unsigned long ulCode;
    
        status = RpcStringBindingCompose(pszUuid,
                                         pszProtocolSequence,
                                         pszNetworkAddress,
                                         pszEndpoint,
                                         pszOptions,
                                         &pszStringBinding);
    	ShowRpcStatus(status);
    	if (status)
    	{
    		exit(status);
    	}
    
        status = RpcBindingFromStringBinding(pszStringBinding, &hello_IfHandle);
    	ShowRpcStatus(status);
    	if (status)
    	{
    		exit(status);
    	}
    
        RpcTryExcept
        {
            HelloProc(pszString);
            Shutdown();
        }
        RpcExcept(1)
        {
            ulCode = RpcExceptionCode();
            printf("Runtime reported exception 0x%lx = %ld\n", ulCode, ulCode);
    		ShowRpcStatus(ulCode);
        }
        RpcEndExcept
    
        status = RpcStringFree(&pszStringBinding);
    	ShowRpcStatus(status);
    	if (status)
    	{
    		exit(status);
    	}
    
        status = RpcBindingFree(&hello_IfHandle);
    	ShowRpcStatus(status);
    	if (status)
    	{
    		exit(status);
    	}
    
        exit(0);
    }
    
    /******************************************************/
    /*         MIDL allocate and free                     */
    /******************************************************/
    
    void __RPC_FAR * __RPC_USER midl_user_allocate(size_t len)
    {
        return(malloc(len));
    }
    
    void __RPC_USER midl_user_free(void __RPC_FAR * ptr)
    {
        free(ptr);
    }
    i debugged the code and it executes the line HelloProc(pszString); in the RpcTryExceptfunction but then it jumps out and executes the code in RpcExcept(1)

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: access denied in client

    From http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx:
    Note RPC Interface Restriction may cause this application to fail with an Access denied error on Windows XP with Service Pack 2 (SP2) and later versions of Windows. For more information, see RPC Interface Restriction.
    Victor Nijegorodov

  3. #3
    Join Date
    Mar 2013
    Posts
    30

    Re: access denied in client

    How do I resolve these issues?
    There are three options to resolve these issues. These options are listed in order of preference.
    Require your RPC clients to use RPC security when contacting your server application. This is the best method to mitigate security threats.
    Exempt your interface from requiring authentication by setting the RPC_IF_ALLOW_CALLBACKS_WITH_NO_AUTH flag during interface registration. This configures RPC to allow anonymous connections to only your application’s interface.
    Force RPC to exhibit the same behavior as earlier versions of Windows by setting the registry key to RPC_RESTRICT_REMOTE_CLIENT_NONE (0). RPC will then accept anonymous connections to all interfaces. This option should be avoided if possible, as it reduces the overall security of the computer.
    i am not really sure what i need to change in my program

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: access denied in client

    You first have to test all these possible options in your PC and some network.
    Then you will have to instruct the customers of your software what registry options must be changed/set to allow your programs to work properly.
    Victor Nijegorodov

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured