User profile cannot be loaded with event ID 1509, 1504

This is a user profile issue.

Some clients log on with temporary profile with error “User Profile Service failed the logon. User profile cannot be loaded”. Event id 1509 can be found in the application event log. The detail of the event id 1509 is something like below:

EventID 1509:
Windows cannot copy file \serverstuprofiles$mandatoryusstudent.V2AppDataLocalMicrosoftWindowsTemporary Internet FilesLowContent.IE51240I065rerB_DjUStFFe16SFEk84lWs2Osh6fwMPJxC1rA8Qwo3EktjoDVd_D0iWDKfepWLE.u7QlPbk.LXlOspXArg7uJna_L8I4Pwi6RfmQLZSAeLvyy0aLgws4xxKwEDnFCvly9zCn9yGMH5Tmf1_yA2fnT[1].M- to location C:UsersusstudentAppDataLocalMicrosoftWindowsTemporary Internet FilesLowContent.IE51240I065rerB_DjUStFFe16SFEk84lWs2Osh6fwMPJxC1rA8Qwo3EktjoDVd_D0iWDKfepWLE.u7QlPbk.LXlOspXArg7uJna_L8I4Pwi6RfmQLZSAeLvyy0aLgws4xxKwEDnFCvly9zCn9yGMH5Tmf1_yA2fnT[1].M-. This error may be caused by network problems or insufficient security rights.
DETAIL - The filename or extension is too long.

 

 

 

This can happen if the destination path of the users profile is on a server with a long server and sharename, e.g. \servernamethisistheprofileshare As the file is stored locally on "c:usersusername" the filename for copying to the destination will increase when this prefix is changed to "\servernamethisistheprofileshare" leading to a pathname longaer than the supported 260 chars.

We found several resolutions, choose one of them will fix this issue:

 

1.    You can use the " Empty Temporary Internet Files folder when browser is closed " option in Internet Explorer to delete all cached Internet files when a user quits Internet Explorer. This option does not delete cookie information. Cookie information (which is usually small) is copied when the profile is saved. To use this option, follow these steps:

In Internet Explorer, click Internet Options on the View (or Tools) menu.
Click the Advanced tab.
Under Security, click the "Delete saved pages when browser closed" or "Empty Temporary Internet Files folder when browser is closed" check box to select it.
Click OK.
 

2.    Create a script to delete the file under temporary files . Here is the script below

strFolder = "C:Documents and SettingsLocalServiceLocal SettingsTemporary Internet FilesContent.IE5"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolders = objFSO.GetFolder(strFolder)
FRecurse objFolders
DRecurse objFolders
Sub FRecurse(ByRef objFolders)
    Set objSubFolders = objFolders.SubFolders
    Set objFiles = objFolders.Files
    For each File in objFiles
 If LCase(File.Name) = "index.dat" Then
 Else
         File.Delete
 End If
    Next
    For each Folder in objSubFolders
        FRecurse Folder
    Next
    Set objSubFolders = Nothing
    Set objFiles = Nothing
End Sub
Sub DRecurse(ByRef objFolders)
    Set objSubFolders = objFolders.SubFolders
    Set objFiles = objFolders.Files
    For each Folder in objSubFolders
        Folder.Delete
    Next
    Set objSubFolders = Nothing
    Set objFiles = Nothing
End Sub
You can also integrate this with task scheduler to run it regularly and ensure you web client cache is flushed regularly.
3.    Enable GPO "Deleted cached copies of roaming profiles"

 

3/7/2011,edit:

Starting January, 2011, the customers reported some of users with roaming profiles having trouble logging onto their XP machines.  When a user tries to log in they get an error message stating:

"Windows cannot copy file C:Documents and SettingsusernameCookiesfilename.txt to location \servernameprofiles$usernameCookiesfilename.txt.  Possible causes of this error include network problems or insufficient security rights.  If this problem persists, contact your network administrator.

DETAIL - Access is denied"

Windows then logs the user in with a temp local profile and the user's settings from the roaming profile does not get loaded.

Analysis:
=========
Looks like this problem caused by Macfee according to the post https://community.mcafee.com/thread/31975
Solution:
=========
First, please check if you have the latest 5.2.1 version of the McAfee software. As this issue is being resolved for a lot of Customers using the new version.
If you are still facing the issue, please follow the below step.
Disable the cookie scanning from the registry :
HK_Local_machinesoftwareMcafeeSystemCoreVSCoreOn Acess ScannerMchieldConfiguration . The Dword is “ScanCookies” , the default value is “ 1” , change it to “0”

Reference:

https://social.technet.microsoft.com/Forums/en-US/winservergen/thread/c3049278-98de-4490-81b0-069cb9b511ea

https://social.technet.microsoft.com/Forums/en-US/winservergen/thread/1573a61c-935f-4ca8-bd64-802817c1a233