private static extern RpcError RpcServerInqCallAttributes(IntPtr binding, [In, Out] ref RPC_CALL_ATTRIBUTES_V2 attributes);
private RPC_CALL_ATTRIBUTES_V2 GetCallInfo() { if ((int)this._callAttrs.Version != 0) { return(this._callAttrs); } RPC_CALL_ATTRIBUTES_V2 attributes = new RPC_CALL_ATTRIBUTES_V2(); attributes.Version = 2U; attributes.Flags = RPC_CALL_ATTRIBUTES_FLAGS.RPC_QUERY_NO_AUTH_REQUIRED; RpcError rpcError1 = RpcClientInfo.RpcServerInqCallAttributes(this._clientHandle, ref attributes); if (rpcError1 == RpcError.RPC_S_INVALID_ARG) { attributes.Version = 1U; rpcError1 = RpcClientInfo.RpcServerInqCallAttributes(this._clientHandle, ref attributes); } if (rpcError1 == RpcError.RPC_S_OK) { this._callAttrs = attributes; this._isAuthenticated = false; attributes.Flags = RPC_CALL_ATTRIBUTES_FLAGS.RPC_QUERY_IS_CLIENT_LOCAL | RPC_CALL_ATTRIBUTES_FLAGS.RPC_QUERY_NO_AUTH_REQUIRED; RpcError rpcError2; if ((rpcError2 = RpcClientInfo.RpcServerInqCallAttributes(this._clientHandle, ref attributes)) == RpcError.RPC_S_OK) { this._callAttrs.IsClientLocal = attributes.IsClientLocal; if (this._callAttrs.ProtocolSequence == RpcProtoseqType.LRPC) { attributes.Flags = RPC_CALL_ATTRIBUTES_FLAGS.RPC_QUERY_CLIENT_PID; if ((rpcError2 = RpcClientInfo.RpcServerInqCallAttributes(this._clientHandle, ref attributes)) == RpcError.RPC_S_OK) { this._callAttrs.ClientPID = attributes.ClientPID; } } } if (this._callAttrs.ProtocolSequence != RpcProtoseqType.LRPC) { using (Ptr <byte[]> ptr1 = new Ptr <byte[]>(new byte[1024])) { RPC_CALL_LOCAL_ADDRESS_V1 data = new RPC_CALL_LOCAL_ADDRESS_V1(); data.Version = 1U; data.Buffer = ptr1.Handle; data.BufferSize = 1024; data.AddressFormat = RpcLocalAddressFormat.Invalid; this._callAttrs = attributes; using (Ptr <RPC_CALL_LOCAL_ADDRESS_V1> ptr2 = new Ptr <RPC_CALL_LOCAL_ADDRESS_V1>(data)) { attributes.CallLocalAddress = ptr2.Handle; attributes.Flags = RPC_CALL_ATTRIBUTES_FLAGS.RPC_QUERY_CALL_LOCAL_ADDRESS | RPC_CALL_ATTRIBUTES_FLAGS.RPC_QUERY_NO_AUTH_REQUIRED; if ((rpcError2 = RpcClientInfo.RpcServerInqCallAttributes(this._clientHandle, ref attributes)) == RpcError.RPC_S_OK) { this._clientAddress = new byte[ptr2.Data.BufferSize]; Array.Copy((Array)ptr1.Data, (Array)this._clientAddress, this._clientAddress.Length); } } } } using (Ptr <byte[]> ptr = new Ptr <byte[]>(new byte[1024])) { attributes.ClientPrincipalName = ptr.Handle; attributes.ClientPrincipalNameBufferLength = 1024; attributes.Flags = RPC_CALL_ATTRIBUTES_FLAGS.RPC_QUERY_CLIENT_PRINCIPAL_NAME; if ((rpcError2 = RpcClientInfo.RpcServerInqCallAttributes(this._clientHandle, ref attributes)) == RpcError.RPC_S_OK) { this._clientPrincipalName = Marshal.PtrToStringUni(ptr.Handle); if (!string.IsNullOrEmpty(this._clientPrincipalName)) { this._isAuthenticated = true; if ((int)attributes.Version == 1) { this._callAttrs.IsClientLocal = RpcCallClientLocality.Local; } } } } } return(this._callAttrs); }