Developer forum

Forum » Development » Folder and files permission in frontend

Folder and files permission in frontend


Reply
I have an extranet site, where the users only must see specific folders/files. In the filemanager I can apply these permissions, but how can I use these in a front end module (File Publishing?)

Replies

 
Reply

Hi. Permissions in file manager works only for backend users.
You can't apply these permissions in file publishing,

We plan to implement this functionality.




 
Reply
Hi Yury,

Tanks fore your reply.

Is there some way in the API check the users permission to a given folder or file?
 
Reply

Hi.
To check permission you can use next code: 
' get current user ID
Dim UserID As Integer = Base.ChkNumber(Session("DW_Admin_UserID"))

'get user’s groups
Dim arrUserGroups As String = Join(CType(Session("DW_Admin_Group"), String()), ",")
'get folders where the user has access

Dim strAllAccessableFolders As String = Base.GetUserElementAccess("folder", UserID & "," & arrUserGroups, "")
'split folder to array
Dim arrAccessFolderList() As String = Split(strAllAccessableFolders, ",")
'get all folders with limited access
Dim strAllRestrictedFolders As String = Base.GetAccessElements("folder")
'split folder to array
Dim arrAllRestrictedFolders() As String = Split(strAllRestrictedFolders, ",")


'check does current user has access to the folder
If IsArray(arrAccessFolderList) Then           

    If
Base.IsValueInArray(arrAllRestrictedFolders, dirName) Then

      If Not Base.IsValueInArray(arrAccessFolderList, dirName) Then
                  Return False
      End If
    End If
End If
Return True

You can check only folders access. Files permissions are not supported.

Hope it will help you.

 
Reply

Is the above code any different from using the following methods in the API?

Dynamicweb.Security.HasAccessToFile("");
Dynamicweb.Security.HasAccessToFolder("");

/Morten
 
Reply
Morten is right. These methods wrap my code. 

Method "HasAccessToFile" handles access to files inside "Security folder". Read for details: http://manual.dynamicweb-cms.com/Default.aspx?ID=1518
 

 

 
Reply
Thanks Morten and Yury, just wat I was looking for.

 

You must be logged in to post in the forum