2010-11-01 48 views
1

我的應用需要將文件寫入(並將其移動)到非管理員用戶的文件夾,並且該用戶沒有權限使用該文件夾。在非管理員Mac上更改RealBASIC權限

我試着改變文件夾的權限,但它似乎沒有效果。

是否有內置限制允許我這樣做?

我要做的就是寫文檔,然後嘗試移動到文件夾最後,它失敗...

感謝您的答案!

下面是代碼:

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 

回答

2

操作系統是旨在阻止這樣的事情,因爲它是一個巨大的安全漏洞,否則

+0

OK,這就是我所想的。客戶正在竊聽我好幾個月,我需要知道。 – 2010-11-01 23:22:46

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作爲AuthorizationMBS

+0

BKeeney - 謝謝!我得看看客戶想要去哪裏... – 2010-11-02 02:50:06