/* * netr_setup_identity * * Set up the client identity information. All of this information is * specifically related to the client user and workstation attempting * to access this system. It may not be in our primary domain. * * I don't know what logon_id is, it seems to be a unique identifier. * Increment it before each use. */ static void netr_setup_identity(ndr_heap_t *heap, smb_logon_t *user_info, netr_logon_id_t *identity) { static mutex_t logon_id_mutex; static uint32_t logon_id; (void) mutex_lock(&logon_id_mutex); if (logon_id == 0) logon_id = 0xDCD0; ++logon_id; user_info->lg_logon_id = logon_id; (void) mutex_unlock(&logon_id_mutex); identity->parameter_control = 0; identity->logon_id.LowPart = logon_id; identity->logon_id.HighPart = 0; ndr_heap_mkvcs(heap, user_info->lg_domain, (ndr_vcstr_t *)&identity->domain_name); ndr_heap_mkvcs(heap, user_info->lg_username, (ndr_vcstr_t *)&identity->username); /* * Some systems prefix the client workstation name with \\. * It doesn't seem to make any difference whether it's there * or not. */ ndr_heap_mkvcs(heap, user_info->lg_workstation, (ndr_vcstr_t *)&identity->workstation); }
/* * samr_create_user * * Create a user in the domain specified by the domain handle. If this * call is successful, the server will return the RID for the user and * a user handle, which may be used to set or query the SAM. * * Observed status codes: * NT_STATUS_INVALID_PARAMETER * NT_STATUS_INVALID_ACCOUNT_NAME * NT_STATUS_ACCESS_DENIED * NT_STATUS_USER_EXISTS * * Returns 0 on success. Otherwise returns an NT status code. */ DWORD samr_create_user(mlsvc_handle_t *domain_handle, char *username, DWORD account_flags, DWORD *rid, mlsvc_handle_t *user_handle) { struct samr_CreateUser arg; ndr_heap_t *heap; int opnum; int rc; DWORD status = 0; if (ndr_is_null_handle(domain_handle) || username == NULL || rid == NULL) { return (NT_STATUS_INVALID_PARAMETER); } opnum = SAMR_OPNUM_CreateUser; bzero(&arg, sizeof (struct samr_CreateUser)); (void) memcpy(&arg.handle, &domain_handle->handle, sizeof (ndr_hdid_t)); heap = ndr_rpc_get_heap(domain_handle); ndr_heap_mkvcs(heap, username, (ndr_vcstr_t *)&arg.username); arg.account_flags = account_flags; arg.desired_access = 0xE00500B0; rc = ndr_rpc_call(domain_handle, opnum, &arg); if (rc != 0) { status = NT_STATUS_INVALID_PARAMETER; } else if (arg.status != 0) { status = NT_SC_VALUE(arg.status); if (status != NT_STATUS_USER_EXISTS) { smb_tracef("SamrCreateUser[%s]: %s", username, xlate_nt_status(status)); } } else { ndr_inherit_handle(user_handle, domain_handle); (void) memcpy(&user_handle->handle, &arg.user_handle, sizeof (ndr_hdid_t)); *rid = arg.rid; if (ndr_is_null_handle(user_handle)) status = NT_STATUS_INVALID_HANDLE; else status = 0; } ndr_rpc_release(domain_handle); return (status); }