How To Recover Your Perforce Admin Account
Bypassing all perforce security and authentication when you can't log in at all.
Some real, practical advice: A how-to for when you screw up.
Hobbyists: you will lock yourself out of your Perforce server.
Anyone who’s been even remotely adjacent to any kind of programming has probably heard the name “github”, or at very least “version control”. Version control is a way to collaboratively store work and edit history on files to allow many people to work on the same thing at the same time while tracking changes.
In game development though, we mostly use Perforce, because of how it handles large files, and that much of our work involves binary files rather than plain text.
Hobbyists and people getting their first projects set up can get away with a default local perforce server, but if you want to start working on something from other locations, or get your friends to join in, then you’re going to need authentication.
“Sounds great”, you say, “I’m in”.
Perforce is really easy to set up and get going because it’s default settings are very open. A user will be automatically created for you if you try to do anything. Passwords aren’t required. That’s fine for running a private server on your network, but you want to share one with your friends, and you know better than to put a server on the public internet with no security.
So you set a password on your account - the only account - which is also the admin account. You’ll disable automatic account creation. You’ll set the security level to 1, to enforce having passwords.
Then you’ll forget about your game for six months, not log in, and forget your password, and you’ll be screwed because all the Perforce documents assume that you have the ability to log in as SOME other user, which in a studio situation you would.
So here’s the ACTUAL recovery process, for Windows Helix Server (aka Perforce).
Start Button → Services
Stop the Perforce server
Open a file browser to your Perforce Server folder. On Windows, that’s probably C:\Program Files\Perforce\Server
Move the db.protect file out of the folder to somewhere else. Don’t delete it. This will be recreated when you start the server again, but if for some reason you need to roll back, delete the new file and put the old one back. This is just for backup purposes.
Open a command prompt as Administrator
Usually when you use perforce CLI commands, you’re using the client (p4.exe) to send commands to the server remotely. However, you can’t log in with the client, because of all that security you put on it. So we’re going to use the server executable itself (p4d.exe) to rewrite its own configuration file.
We need to pass two arguments to p4d.exe:
-r “c:\Program Files\Perforce\Server” (or whatever your server folder is)
“-cshow” (which is short for ‘config show’)This prints out the configuration options currently set. These two are our problem.
dm.user.noautocreate = 2 (new users need to be created manually by admin)
security = 1 (passwords are required)
Sidenote: on Windows, you need double quotes around any of the config show, set or unset commands. (cshow, cset, cunset)We’re going to set those to 0, so we can create a user and log in.
p4d -r "c:\Program Files\Perforce\Server" "-cset dm.user.noautocreate=0”
p4d -r "c:\Program Files\Perforce\Server" "-cset security=0"Much better.
Now, you can restart the Perforce server. Mine is already running here:
Any p4 action now will create a new user. The simplest action is a “ping”. Use this to create a user, set a password, then log in with it. We use the -u argument to specify a username to execute as, then the ping command:
p4 -u christina pingYou can see there is no ‘christina’ user, until I perform an action claiming to be user ‘christina’. As soon as I do, the user is created. After that, I’m able to set a password, and then log in.
You may now use the newly created account (in my case, ‘christina’) to edit the password of your old account:
p4 -u christina passwd oldaccountnamegoeshere
So now we’ve got a new account, we’ve reset our old account, all that’s left is to bring back the administrator privileges.Run P4ADMIN to open the administration console, and connect to your server with your new user. It should tell you that if you proceed, you will be the only super user in the system. Say yes. You may need to disconnect and reconnect after this for the UI to update with full super-user access. Congratulations! You now have full control of the server, and are free to restore your old account to superuser, or whatever else you’d prefer.
Woohoo! You’ve done it.
Don’t forget to reset your auth permissions. These were mine, yours might have been different. Back to your administrator command prompt:
p4d -r "c:\Program Files\Perforce\Server" "-cset dm.user.noautocreate=2”
p4d -r "c:\Program Files\Perforce\Server" "-cset security=1"
WHEW. What a mission. Save your password somewhere next time, or keep a backup user with no real permissions except login, with a dumb password you can’t forget, and then you only have to do the db.protect step, as listed here.
Until next time.
for those we have lost
for those we can yet save