| Previous | Next |
| ERROR_CONNECTED_OTHER_PASSWORD_DEFAULT | ERROR_NOT_CONNECTED |
ERROR_BAD_USERNAME
The specified user name is invalid.
ERROR_BAD_USERNAME is Win32 error 2202 (0x89A). In a WNet or provider context, the code rejects the identity string before or during connection setup. It does not by itself mean that a syntactically valid account has the wrong password or lacks access to the remote resource.
Common username defects
- the string uses a malformed
DOMAIN\user, user-principal-name, or provider-specific format - configuration contains an empty value, surrounding quotes, control characters, or trailing whitespace
- a byte/character encoding mismatch truncates or corrupts a non-ASCII account name
- the application places a server or share name in the username field
- a service passes a display label or email-like identifier where the provider expects a Windows logon name
Useful and safe evidence
Record the WNet API, provider, target resource, username format category, character count, normalization result, domain/UPN split success, source configuration field, process identity, and exact error. Mask most account characters in routine logs and never record the accompanying password.
Diagnostic sequence
Validate the string locally according to the identity format promised by the product. Display invisible characters and verify Unicode handling. Test the same account through an authoritative sign-in or directory lookup without changing the password first.
Separate format from existence and authorization. A different result with a clearly formed account can then be investigated as unknown user, logon failure, restriction, or access denied. Check provider-specific extended errors through WNetGetLastError when available.
Recovery and validation
Correct the account form, remove accidental quoting or whitespace, and retry once with the same approved secret. Do not cycle through guessed domains or alternate usernames because that creates lockout and audit noise.
Interfaces should label accepted formats, preserve Unicode, and validate configuration at entry time. Managed deployments should store account identity separately from target resource and secret identifiers.
Difference from authentication failure
An authentication failure means a recognizable account/password or policy check was rejected. Error 2202 says the supplied username representation itself is invalid for the attempted network operation.
Example
A service reads "CONTOSO\backup", including literal quote characters, from JSON and passes it to WNet. The provider returns 2202. Parsing the JSON value correctly yields CONTOSO\backup and allows normal authentication diagnostics.
References
- Microsoft: System Error Codes (1700–3999)
- Microsoft: Win32 Error Codes in MS-ERREF
- Microsoft: Windows Networking (WNet)
- Microsoft: WNetAddConnection2
- Microsoft: WNetGetLastError
Looking for a different code? Search another status or error code.