If users get this error:
Fatal error: $CFG->dataroot is not writable, admin has to fix directory permissions! Exiting.
when trying to login to moodle, most probably (and obivously from the error itself) they do not have the write permission to dataroot folder defined in config.php for example:
$CFG->dataroot = 'C:\\inetpub\\moodle\\moodledata';
In my case on windows web server I was using SSO (Single Sign On) via NTLM, so the solution was to give "Modify" permissions for "Authenticated Users". After that automatic logons started to work as intended.
Of course you don't have to give permissions for all authenticated users, only the users who actually will be loging to moodle need them.