/// <summary> /// Handle LsarClose response sent event. /// </summary> /// <param name="messageToSend">LsarCloseResponse</param> private void HandleLsarCloseResponse(LsaResponseStub messageToSend) { LsarCloseRequest request = requestReceived as LsarCloseRequest; LsarCloseResponse response = messageToSend as LsarCloseResponse; if (request != null && response != null) { if (response.Status == NtStatus.STATUS_SUCCESS) { if (policyContext.ContainsKey(request.ObjectHandle.Value)) { policyContext.Remove(request.ObjectHandle.Value); } else if (accountContext.ContainsKey(request.ObjectHandle.Value)) { accountContext.Remove(request.ObjectHandle.Value); } else if (secretContext.ContainsKey(request.ObjectHandle.Value)) { secretContext.Remove(request.ObjectHandle.Value); } else if (trustedDomainContext.ContainsKey(request.ObjectHandle.Value)) { trustedDomainContext.Remove(request.ObjectHandle.Value); } } } }
internal void UpdateSessionContextWithMessageSent(LsaResponseStub messageToSend) { switch (messageToSend.Opnum) { case LsaMethodOpnums.LsarClose: HandleLsarCloseResponse(messageToSend); break; case LsaMethodOpnums.LsarOpenPolicy: HandleLsarOpenPolicyResponse(messageToSend); break; case LsaMethodOpnums.LsarCreateAccount: HandleLsarCreateAccountResponse(messageToSend); break; case LsaMethodOpnums.LsarCreateTrustedDomain: HandleLsarCreateTrustedDomainResponse(messageToSend); break; case LsaMethodOpnums.LsarCreateSecret: HandleLsarCreateSecretResponse(messageToSend); break; case LsaMethodOpnums.LsarOpenAccount: HandleLsarOpenAccountResponse(messageToSend); break; case LsaMethodOpnums.LsarOpenTrustedDomain: HandleLsarOpenTrustedDomainResponse(messageToSend); break; case LsaMethodOpnums.LsarOpenSecret: HandleLsarOpenSecretResponse(messageToSend); break; case LsaMethodOpnums.LsarDeleteObject: HandleLsarDeleteObjectResponse((LsarDeleteObjectResponse)messageToSend); break; case LsaMethodOpnums.LsarOpenPolicy2: HandleLsarOpenPolicy2Response(messageToSend); break; case LsaMethodOpnums.LsarCreateTrustedDomainEx: HandleLsarCreateTrustedDomainExResponse(messageToSend); break; case LsaMethodOpnums.LsarOpenTrustedDomainByName: HandleLsarOpenTrustedDomainByNameResponse(messageToSend); break; case LsaMethodOpnums.LsarCreateTrustedDomainEx2: HandleLsarCreateTrustedDomainEx2Response(messageToSend); break; default: break; } }
/// <summary> /// Sends RPC response to the client /// </summary> /// <param name="sessionContext">The session context of the RPC response to send</param> /// <param name="messageToSend">The RPC response to send</param> /// <exception cref="ArgumentNullException"> /// Thrown when sessionContext or messageToSend is null. /// </exception> public void SendRpcCallResponse(LsaServerSessionContext sessionContext, LsaResponseStub messageToSend) { CheckIfSessionContextIsNull(sessionContext); if (messageToSend == null) { throw new ArgumentNullException("messageToSend"); } sessionContext.UpdateSessionContextWithMessageSent(messageToSend); rpceLayerServer.SendResponse(sessionContext.RpceLayerSessionContext, messageToSend.Encode(sessionContext)); }
/// <summary> /// Handle LsarCreateTrustedDomainEx2 response event. /// </summary> /// <param name="messageToSend">LsarCreateTrustedDomainEx2Response</param> private void HandleLsarCreateTrustedDomainEx2Response(LsaResponseStub messageToSend) { LsarCreateTrustedDomainEx2Request request = requestReceived as LsarCreateTrustedDomainEx2Request; LsarCreateTrustedDomainEx2Response response = messageToSend as LsarCreateTrustedDomainEx2Response; if (request != null && response != null) { if (response.Status == NtStatus.STATUS_SUCCESS) { trustedDomainContext.Add(response.TrustedDomainHandle, request.DesiredAccess); } } }
/// <summary> /// Handle LsarOpenSecret response event. /// </summary> /// <param name="messageToSend">LsarOpenSecretResponse</param> private void HandleLsarOpenSecretResponse(LsaResponseStub messageToSend) { LsarOpenSecretRequest request = requestReceived as LsarOpenSecretRequest; LsarOpenSecretResponse response = messageToSend as LsarOpenSecretResponse; if (request != null && response != null) { if (response.Status == NtStatus.STATUS_SUCCESS) { secretContext.Add(response.SecretHandle, request.DesiredAccess); } } }