1

我的应用程序需要将文件从非管理员用户写入(和移动)到文件夹,并且该用户无权使用该文件夹。

我尝试更改文件夹的权限,但似乎没有效果。

允许我这样做有内置限制吗?

我所做的是写入文档,然后尝试将文件移动到最终文件夹,但失败了......

感谢您的任何回答!

这是代码:

  Dim t as TextOutputStream
  Dim tempfile as FolderItem = SpecialFolder.Documents.Child(filePath.Name)

  t = tempfile.CreateTextFile
  t.Write fileData
  t.close

  Dim p as New Permissions( 0 )

  p.OthersExecute = True
  p.OthersWrite = True
  p.OthersRead = True

  filePath.Parent.Permissions = p

  tempfile.MoveFileTo filePath.Parent
4

2 回答 2

2

假设用户可以提升安全级别,您可以使用 Monkeybread 软件插件 AuthorizationMBS 中的功能之一来允许授权。在我必须进入系统位置的一类中,我有这个:

Protected Function mbsAuthorize() As boolean
  dim a as AuthorizationMBS
  dim s(2) as String

  if mbsAuthorized then
    mbsForm = mbsAuth.ExternalForm
    Return true
  else
    a = New AuthorizationMBS
    If a.NewAuthorization(nil, a.kAuthorizationFlagPreAuthorize) Then
      a.SimpleAuthorize

      if a.Authorized then
        mbsAuth=a // save so the externalform doesn't get invalid
        mbsForm=a.ExternalForm // copy to string for later use.
        Return true
      end if
    else
      break
    End if
  end

  return false
End Function

该类具有以下属性:

mbsForm 作为字符串

mbsAuth 作为授权MBS

于 2010-11-01T23:40:37.487 回答
2

该操作系统旨在阻止此类事情,否则它是一个巨大的安全漏洞

于 2010-11-01T21:31:04.937 回答