/* * lsar_close * * Close the LSA connection associated with the handle. The lsa_handle * must be a valid handle obtained via a call to lsar_open_policy2 or * lsar_open_account. On success the handle will be zeroed out to * ensure that it is not used again. If this is the top level handle * (i.e. the one obtained via lsar_open_policy2) the pipe is closed. * * Returns 0 on success. Otherwise non-zero to indicate a failure. */ int lsar_close(mlsvc_handle_t *lsa_handle) { struct mslsa_CloseHandle arg; int opnum; if (ndr_is_null_handle(lsa_handle)) return (-1); opnum = LSARPC_OPNUM_CloseHandle; bzero(&arg, sizeof (struct mslsa_CloseHandle)); (void) memcpy(&arg.handle, lsa_handle, sizeof (mslsa_handle_t)); (void) ndr_rpc_call(lsa_handle, opnum, &arg); ndr_rpc_release(lsa_handle); if (ndr_is_bind_handle(lsa_handle)) ndr_rpc_unbind(lsa_handle); bzero(lsa_handle, sizeof (mlsvc_handle_t)); return (0); }
/* * samr_close_handle * * This is function closes any valid handle, i.e. sam, domain, user etc. * If the handle being closed is the top level connect handle, we unbind. * Then we zero out the handle to invalidate it. */ int samr_close_handle(mlsvc_handle_t *samr_handle) { struct samr_CloseHandle arg; int opnum; if (ndr_is_null_handle(samr_handle)) return (-1); opnum = SAMR_OPNUM_CloseHandle; bzero(&arg, sizeof (struct samr_CloseHandle)); (void) memcpy(&arg.handle, &samr_handle->handle, sizeof (ndr_hdid_t)); (void) ndr_rpc_call(samr_handle, opnum, &arg); ndr_rpc_release(samr_handle); if (ndr_is_bind_handle(samr_handle)) ndr_rpc_unbind(samr_handle); bzero(samr_handle, sizeof (mlsvc_handle_t)); return (0); }