Saturday, September 3, 2016

"net user" doesn't tell you if the username is too long

Yesterday, I was debugging a crash in a routine that creates a new temporary user account with a random name. Even though I made sure to only use valid characters in the name, the exception message specified that the username is invalid. I then went to try one generated name with net user, like so:

net user TempUser-ReallySuperLongName RandomPassword /add

It replied with the syntax reference for that subcommand, while shorter usernames involving the same characters worked. Evidently, the maximum SAM account name length is 20 characters. The utility doesn't tell you that, but that's the limit.

No comments:

Post a Comment