RpcBindingSetAuthInfo

The RpcBindingSetAuthInfo function sets authentication and authorization information into a binding handle.

#include <rpc.h>
RPC_STATUS RPC_ENTRY RpcBindingSetAuthInfo( 
  RPC_BINDING_HANDLE  hBinding,             
  unsigned char * ServerPrincName,          
  unsigned long  AuthnLevel,                
  unsigned long  AuthnService,              
  RPC_AUTH_IDENTITY_HANDLE  AuthIdentity,   
  unsigned long  AuthzService               
);
 

Parameters

hBinding
The server binding handle to which authentication and authorization information is to be applied.
ServerPrincName
Points to the expected principal name of the server referenced by hBinding. The content of the name and its syntax are defined by the authentication service in use. Set this parameter to NULL when accessing the Microsoft Message Queue Server (MSMQ) Security.
AuthnLevel
Specifies the level of authentication to be performed on remote procedure calls made using the hBinding binding handle. For a list of the RPC-supported authentication levels, see Authentication-Level Constants in the RPC documentation that is part of the Platform SDK online help.

Under MSMQ security this can be RPC_C_AUTHN_LEVEL_NONE, RPC_C_AUTHN_LEVEL_PKT_INTEGRITY, or RPC_C_AUTHN_LEVEL_PKT_PRIVACY. If you specify any other level it will be converted silently to the next higher supported level.

AuthnService
The authentication service to use. For a list of the RPC-supported authentication services, see Authentication-Service Constants

Specify RPC_C_AUTHN_NONE to turn off authentication for remote procedure calls made using the hBinding binding handle.

If RPC_C_AUTHN_DEFAULT is specified, the RPC run-time library uses the RPC_C_AUTHN_WINNT authentication service for remote procedure calls made using the hBinding binding handle.

The only authentication services allowed for MSMQ security are RPC_C_AUTHN_NONE and RPC_C_AUTHN_MQ. If you use RPC_C_AUTHN_WINNT or one of the other security providers your message calls will not be authenticated or encrypted.

AuthIdentity
A handle for the data structure that contains the client's authentication and authorization credentials appropriate for the selected authentication and authorization service.

When using the RPC_C_AUTHN_WINNT authentication service AuthIdentity should be a pointer to a SEC_WINNT_AUTH_IDENTITY structure (defined in rpcdce.h).

Specify a null value to use the security login context for the current address space.

AuthzService
The authorization service implemented by the server for the interface of interest. For a list of RPC-supported authorization services see Authorization-Service Constants in the RPC documentation that is part of the Platform SDK online help.

The validity and trustworthiness of authorization data, like any application data, depends on the authentication service and authentication level selected. This parameter is ignored when using the RPC_C_AUTHN_WINNT authentication service.

Return Values

Value Meaning
RPC_S_OK Success.
RPC_S_INVALID_BINDING Invalid binding handle.
RPC_S_WRONG_KIND_OF_BINDING Wrong kind of binding for operation.
RPC_S_UNKNOWN_AUTHN_SERVICE Unknown authentication service.

Remarks

A client application calls the RpcBindingSetAuthInfo routine to set up a server binding handle for making authenticated remote procedure calls. A client is not required to call this routine.

Unless a client calls RpcBindingSetAuthInfo, no remote procedure calls on the hBinding binding handle are athenticated. A server can call RpcBindingInqAuthClient from within a remote procedure call to determine if that call has been authenticated.

Note  As long as the binding handle exists, RPC maintains a pointer to AuthIdentity. Be sure it is not on the stack and is not freed until the binding handle is freed. If the binding handle is copied, or if a context handle is created from the binding handle, then the AuthIdentity pointer will also be copied.

QuickInfo

  Windows NT: Yes
  Windows CE: Unsupported.
  Header: Declared in rpcdce.h.
  Import Library: Link with rpcrt4.lib.

See Also

RpcBindingSetOption, RpcBindingInqAuthInfo, RpcServerRegisterAuthInfo