TechnitiumSoftware/DnsServer · error · DnsWebServiceException

Cannot create more than 255 users.

Error message

Cannot create more than 255 users.

What it means

Thrown as DnsWebServiceException from CreateUser when _users.Count is already >= 255 (byte.MaxValue) before attempting to add. The hard cap exists because user identifiers are stored as a byte. Returned over the API as HTTP 200 with status 'error'.

Source

Thrown at DnsServerCore/Auth/AuthManager.cs:923

            return null;
        }

        public User GetSsoUser(string ssoIdentifier)
        {
            foreach (KeyValuePair<string, User> user in _users)
            {
                if (ssoIdentifier.Equals(user.Value.SsoIdentifier, StringComparison.Ordinal) && user.Value.IsSsoUser)
                    return user.Value;
            }

            return null;
        }

        public User CreateUser(string displayName, string username, string password, int iterations = User.DEFAULT_ITERATIONS)
        {
            if (_users.Count >= byte.MaxValue)
                throw new DnsWebServiceException("Cannot create more than 255 users.");

            username = username.ToLowerInvariant();

            User user = User.CreateLocalUser(displayName, username, password, iterations);

            if (_users.TryAdd(username, user))
            {
                if (_users.Count > byte.MaxValue)
                {
                    _users.TryRemove(username, out _); //undo
                    throw new DnsWebServiceException("Cannot create more than 255 users.");
                }

                user.AddToGroup(GetGroup(Group.EVERYONE));
                return user;
            }

            throw new DnsWebServiceException("User already exists: " + username);

View on GitHub (pinned to d0484b6c1e)

Solutions

  1. Delete unused user accounts to free slots below 255 before creating new ones.
  2. Consolidate access via groups/SSO rather than creating many local users.
  3. Track _users.Count before calling create when bulk-provisioning.
Defensive patterns

Strategy: validation

Validate before calling

if (await GetUserCountAsync() >= 255)
    throw new InvalidOperationException("User cap (255) reached; delete unused users first.");

Try / catch

try { await client.CreateUserAsync(name, username, password); }
catch (HttpApiClientException ex) when (ex.Message.Contains("Cannot create more than 255 users"))
{
    await FreeUpUserSlotsAsync();
}

Prevention

When it happens

Trigger: Calling CreateUser (POST /api/users/create or similar) when the user dictionary already holds 255 users; the pre-add guard fails fast.

Common situations: Bulk-provisioning users from LDAP/SSO import or a script; long-running server that accumulated users up to the cap.

Related errors


AI-assisted analysis of TechnitiumSoftware/DnsServer@d0484b6c1e (2026-08-13). Data as JSON: /api/errors/31c459bbf209bd1c. Report an issue: GitHub.