internal static extern SecStatusCode AcceptSecurityContext( [In] SecHandle phCredential, [In] SecHandle phContext, SecBufferDesc pInput, AcceptContextReqFlags fContextReq, SecDataRep TargetDataRep, [In, Out] SecHandle phNewContext, [In, Out] SecBufferDesc pOutput, out AcceptContextRetFlags pfContextAttr, [Out] LargeInteger ptsExpiry );
internal static SecStatusCode AcceptSecurityContext( CredentialHandle credential, SecHandle context, AcceptContextReqFlags req_attributes, SecDataRep data_rep, IList <SecurityBuffer> input, SecHandle new_context, IList <SecurityBuffer> output, out AcceptContextRetFlags ret_attributes, LargeInteger expiry, bool throw_on_error) { using (DisposableList list = new DisposableList()) { var input_buffers = input?.ToBufferList(list); var output_buffers = output?.ToBufferList(list); var in_buffer_desc = input_buffers.ToDesc(list); var out_buffer_desc = output_buffers.ToDesc(list); SecStatusCode result = SecurityNativeMethods.AcceptSecurityContext(credential.CredHandle, context, in_buffer_desc, req_attributes, data_rep, new_context, out_buffer_desc, out ret_attributes, expiry).CheckResult(throw_on_error); if (!result.IsSuccess()) { return(result); } try { if (result == SecStatusCode.SEC_I_COMPLETE_NEEDED || result == SecStatusCode.SEC_I_COMPLETE_AND_CONTINUE) { var comp_result = SecurityNativeMethods.CompleteAuthToken(context, out_buffer_desc).CheckResult(throw_on_error); if (!comp_result.IsSuccess()) { return(comp_result); } } } finally { if (result.IsSuccess()) { output?.UpdateBuffers(out_buffer_desc); } } return(result); } }