A couple of weeks back this was the question I got by text message. It was from a friend who had some issues and asked one of his other friends to have a look at it and since then he was totally locked out.
This is the procedure I used to access his Mac.
Removing the setup file.
I booted the system with the command (that weird Apple key for Windows users) + S. This boots the system into single user mode and gives back a terminal.
Next I did a file system check with fsck -fy. The file system was ok.
The following step was to mount the root drive as writable:
mount -uw /
Finally I renamed the .AppleSetupDone
mv /var/db/.AppleSetupDone /var/db/.AppleSetupDone.old
Creating a new Admin.
After the reboot the "Welcome wizard" screen came on, I made a new account, which automatically made me an Admin account.
Reset of the old Admin's password.
The only thing left to do was reset the old admin password. This is done via the system preferences, accounts. You have to unlock the little lock icon at the bottom, and reset the original Admin account.
I logged out of the new admin and logged my friend in to his familiar session.