By deleting a special file you can re-run Setup Assistant to create a new admin user.
Removing .AppleSetupDone to re-run Setup Assistant:
To remove this file, you have to boot to single user mode by pressing ⌘S while booting. After a few moments, you'll see the Mac boot to the command line.
Check the file system and mount your main volume in read/write mode
/sbin/fsck -fy
/sbin/mount -uw /
With the filesystem mounted and accessible, it's time to remove the file so OS X will re-run Setup Assistant:
rm /var/db/.AppleSetupDone
Reboot your Mac with
reboot
If El Capitan is installed you may have to disable SIP before you can remove the file.
After rebooting the Setup Assistant will create a new local admin user without iCloud integration and setup your system. Choose a user name not used previously.
Now open System Preferences -> Users & Group, enter the "Advanced Options" of the admin account and restore the previously working settings of the first admin user.
Log-out of the new admin account and log-in as old admin user and check if it is working. Open System Preferences -> Users & Group and remove the new admin user.