/lsass/server/rpc/samr/samr_contexthandle.c

https://github.com/BeyondTrust/pbis-open · C · 141 lines · 65 code · 26 blank · 50 comment · 4 complexity · 1e18faef0ccd3a8d9b32742830f7d21f MD5 · raw file

  1. /* Editor Settings: expandtabs and use 4 spaces for indentation
  2. * ex: set softtabstop=4 tabstop=8 expandtab shiftwidth=4: *
  3. */
  4. /*
  5. * Copyright © BeyondTrust Software 2004 - 2019
  6. * All rights reserved.
  7. *
  8. * Licensed under the Apache License, Version 2.0 (the "License");
  9. * you may not use this file except in compliance with the License.
  10. * You may obtain a copy of the License at
  11. *
  12. * http://www.apache.org/licenses/LICENSE-2.0
  13. *
  14. * Unless required by applicable law or agreed to in writing, software
  15. * distributed under the License is distributed on an "AS IS" BASIS,
  16. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17. * See the License for the specific language governing permissions and
  18. * limitations under the License.
  19. *
  20. * BEYONDTRUST MAKES THIS SOFTWARE AVAILABLE UNDER OTHER LICENSING TERMS AS
  21. * WELL. IF YOU HAVE ENTERED INTO A SEPARATE LICENSE AGREEMENT WITH
  22. * BEYONDTRUST, THEN YOU MAY ELECT TO USE THE SOFTWARE UNDER THE TERMS OF THAT
  23. * SOFTWARE LICENSE AGREEMENT INSTEAD OF THE TERMS OF THE APACHE LICENSE,
  24. * NOTWITHSTANDING THE ABOVE NOTICE. IF YOU HAVE QUESTIONS, OR WISH TO REQUEST
  25. * A COPY OF THE ALTERNATE LICENSING TERMS OFFERED BY BEYONDTRUST, PLEASE CONTACT
  26. * BEYONDTRUST AT beyondtrust.com/contact
  27. */
  28. /*
  29. * Copyright (C) BeyondTrust Software. All rights reserved.
  30. *
  31. * Module Name:
  32. *
  33. * samr_contexthandle.c
  34. *
  35. * Abstract:
  36. *
  37. * Remote Procedure Call (RPC) Server Interface
  38. *
  39. * Samr context handles
  40. *
  41. * Authors: Rafal Szczesniak (rafal@likewise.com)
  42. */
  43. #include "includes.h"
  44. VOID
  45. SamrSrvConnectContextFree(
  46. PCONNECT_CONTEXT pConnCtx
  47. )
  48. {
  49. InterlockedDecrement(&pConnCtx->refcount);
  50. if (pConnCtx->refcount) return;
  51. if (pConnCtx->hDirectory)
  52. {
  53. DirectoryClose(pConnCtx->hDirectory);
  54. }
  55. SamrSrvFreeAuthInfo(pConnCtx);
  56. LW_SAFE_FREE_MEMORY(pConnCtx);
  57. }
  58. VOID
  59. SamrSrvDomainContextFree(
  60. PDOMAIN_CONTEXT pDomCtx
  61. )
  62. {
  63. InterlockedDecrement(&pDomCtx->refcount);
  64. if (pDomCtx->refcount) return;
  65. RTL_FREE(&pDomCtx->pDomainSid);
  66. LW_SAFE_FREE_MEMORY(pDomCtx->pwszDomainName);
  67. LW_SAFE_FREE_MEMORY(pDomCtx->pwszDn);
  68. SamrSrvConnectContextFree(pDomCtx->pConnCtx);
  69. LW_SAFE_FREE_MEMORY(pDomCtx);
  70. }
  71. VOID
  72. SamrSrvAccountContextFree(
  73. PACCOUNT_CONTEXT pAcctCtx
  74. )
  75. {
  76. InterlockedDecrement(&pAcctCtx->refcount);
  77. if (pAcctCtx->refcount) return;
  78. LW_SAFE_FREE_MEMORY(pAcctCtx->pwszDn);
  79. LW_SAFE_FREE_MEMORY(pAcctCtx->pwszName);
  80. RTL_FREE(&pAcctCtx->pSid);
  81. SamrSrvDomainContextFree(pAcctCtx->pDomCtx);
  82. LW_SAFE_FREE_MEMORY(pAcctCtx);
  83. }
  84. void
  85. CONNECT_HANDLE_rundown(
  86. void *hContext
  87. )
  88. {
  89. PCONNECT_CONTEXT pConnCtx = (PCONNECT_CONTEXT)hContext;
  90. SamrSrvConnectContextFree(pConnCtx);
  91. }
  92. void
  93. DOMAIN_HANDLE_rundown(
  94. void *hContext
  95. )
  96. {
  97. PDOMAIN_CONTEXT pDomCtx = (PDOMAIN_CONTEXT)hContext;
  98. SamrSrvDomainContextFree(pDomCtx);
  99. }
  100. void
  101. ACCOUNT_HANDLE_rundown(
  102. void *hContext
  103. )
  104. {
  105. PACCOUNT_CONTEXT pAcctCtx = (PACCOUNT_CONTEXT)hContext;
  106. SamrSrvAccountContextFree(pAcctCtx);
  107. }
  108. /*
  109. local variables:
  110. mode: c
  111. c-basic-offset: 4
  112. indent-tabs-mode: nil
  113. tab-width: 4
  114. end:
  115. */