private PamStatus HandlePamConversation(int messageCount, IntPtr messageArrayPtr, ref IntPtr responseArrayPtr, IntPtr appDataPtr) { if (messageCount <= 0) { return(PamStatus.PAM_CONV_ERR); } var messages = MarshalUtils.MarshalPtrPtrStructIn <PamMessage>(messageCount, messageArrayPtr); List <PamResponse> responses; try { responses = new List <PamResponse>(this.conversationCallback(messages, appDataPtr)); } catch { return(PamStatus.PAM_CONV_ERR); } if (messageCount == 1) { responseArrayPtr = MarshalUtils.MarshalPtrStructOut <PamResponse>(responses[0]); } else { responseArrayPtr = MarshalUtils.MarshalPtrPtrStructOut <PamResponse>(responses); } return(PamStatus.PAM_SUCCESS); }
public PamStatus HandlePamConversation(int messageCount, IntPtr messageArrayPtr, ref IntPtr responseArrayPtr, IntPtr appDataPtr) { if (messageCount <= 0) { return(PamStatus.PAM_CONV_ERR); } var messages = MarshalUtils.MarshalPtrPtrStructIn <PamMessage>(messageCount, messageArrayPtr); if (messageCount == 1) { responseArrayPtr = MarshalUtils.MarshalPtrStructOut <PamResponse>(new PamResponse(password)); } else { throw new NotSupportedException("NpamAuthentication does not support PAM modules which require responses to multiple conversational messages. Please use NpamSession instead."); } return(PamStatus.PAM_SUCCESS); }