How to fix "The Group Policy Client service failed the logon. Access denied." error?

I stumbled into this error while logging on to one of my machines with my domain account. I searched at "bing" and "google" for help but unfortunately did not find any so after several trial and error, I managed to fix this issue. I am posting it so if any of you run into it, you could give the following a try and if you are lucky hopefully this will work for you.

1. Logon to the machine with a machine administrator account (assuming this issue is with a domain account, if not logon to the machine using another account with administrative privilege).

2. Move the machine to a workgroup from domain. (If it was part of one workgroup then change it to another one or join a domain.) You could do this through Control Panel\System and Security\System and then Change Settings.

3. Restart the machine and logon with a machine administrator account.

4. Delete your user profile data (or move it a different location) completely from c:\users. "C" in my case is system directory but if you have a different one then use that one.

5. Join the machine back to domain account (or to workgroup that the machine was originally joined to), and restart the machine.

6. Logon with your domain account that you were having trouble with. Keep fingers crossed.

If all goes well, you should be logged on.

Since this error may happen under different conditions so the above may not be a solution for all but if it helps even a single soul, I would consider my time writing this blog worth spent.