-static NTSTATUS idmap_autorid_allocate_id(struct idmap_domain *dom,
- struct unixid *xid) {
-
- struct autorid_global_config *globalcfg;
- NTSTATUS ret;
- uint32_t hwm;
-
- if (!strequal(dom->name, "*")) {
- DEBUG(3, ("idmap_autorid_allocate_id: "
- "Refusing creation of mapping for domain'%s'. "
- "Currently only supported for the default "
- "domain \"*\".\n",
- dom->name));
- return NT_STATUS_NOT_IMPLEMENTED;
- }
-
- globalcfg = talloc_get_type(dom->private_data,
- struct autorid_global_config);
-
- ret = dbwrap_fetch_uint32(autorid_db, ALLOC_HWM, &hwm);
- if (!NT_STATUS_IS_OK(ret)) {
- DEBUG(1, ("Failed to fetch current allocation HWM value: %s\n",
- nt_errstr(ret)));
- return NT_STATUS_INTERNAL_ERROR;
- }
-
- if (hwm > ALLOC_POOL_SIZE) {
- DEBUG(1, ("allocation pool is depleted!\n"));
- return NT_STATUS_NO_MEMORY;
- }
-
- ret = dbwrap_change_uint32_atomic(autorid_db, ALLOC_HWM, &(xid->id), 1);
- if (!NT_STATUS_IS_OK(ret)) {
- DEBUG(1, ("Fatal error while allocating new ID!\n"));
- }
- xid->id = (xid->id)+(globalcfg->minvalue);
-
- return ret;
-}
-