Forum Discussion

BenEppel's avatar
BenEppel
New Contributor III
2 days ago

Clearing Files in User Temp Folder as Non Admin

Good afternoon,

Does anybody know which security setting would allow a user to delete files from their Temp Folder?

I have tried changing the below System and Application Security Roles with no luck. Each time i get an error saying the User does not have permission to write to that folder.

Private Sub ClearUserTempFolder(ByVal si As SessionInfo)
    Try
        Dim userName As String = si.UserName.Replace(" ", "")
        Dim location As FileSystemLocation = FileSystemLocation.ApplicationDatabase
        Dim folderPath As String = $"Internal/Users/{userName}/Temp"
        Dim fileTypeFilter As XFFileType = XFFileType.All
        Dim contentFileExtensionFilters As List(Of String) = Nothing

        ' Get list of files
        Dim objList As List(Of XFFileInfoEX) = BRApi.FileSystem.GetFilesInFolder(si, location, folderPath, fileTypeFilter, contentFileExtensionFilters)

        If objList IsNot Nothing AndAlso objList.Count > 0 Then
            For Each file In objList
                Try
                    BRApi.FileSystem.DeleteFile(si, location, file.XFFileInfo.FullName)
                    BRApi.ErrorLog.LogMessage(si, $"Deleted file: {file.XFFileInfo.FullName}")
			Catch ex As Exception
				Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
			End Try            
		Next
        Else
            BRApi.ErrorLog.LogMessage(si, $"No files to delete in {folderPath}")
        End If

			Catch ex As Exception
				Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
			End Try
End Sub

 

1 Reply

  • MarcusH's avatar
    MarcusH
    Valued Contributor

    I think you need to give the user the System permission RetrieveFileShareContents.

    'The Contents Folder is not exposed to the user in the File Share for Application or System using the File Explorer. All files are accessible through the OneStream application, such as through Dashboards and Business Rules.'