These forums are read-only and considered to be an archive. Please use the new Community for future interaction and posts.

Role

Hi,

I want to restrict users to some Roles. For example, some folders have some roles and if the current user is into 'Admin' role and the folder is into 'Admin' role then the folder present for the user. Is this possible?
Mohsen 11/2/2009 5:20 AM
Hi Mohsen,

I think this might be your starting point: 
http://www.gleamtech.com/support/forums/3715/uploaded-event-triggers-itself-randomly-after-upload

enjoy
Kaan Özgen 11/10/2009 5:33 AM
Hi Mohsen, following code worked with me:

                Dim ctrlFileVista As New FileVistaControl
                Dim RootFolder As FileVistaRootFolder

                ctrlFileVista = ctrlFileVista.LoadControl("~\FileVistaControl\filevista.ascx")
                ctrlFileVista.LicenseKey = "temp"
                ctrlFileVista.Style = "width: 100%; height:400px; position:relative; left:10em;"

                Dim userName As String = "USR"
                Dim userFolderName As String = userName
                Dim userFolderPath As String = "~/" & userName

                RootFolder = New FileVistaRootFolder(userFolderName, userFolderPath)
                RootFolder.Permissions = FileVistaPermissions.Full
                ctrlFileVista.RootFolders.Add(RootFolder)
                Me.mainInfo.Controls.Add(ctrlFileVista)

You can easily play around. All you have to do is to gather the authenticated role and load the control accordingly.

Regards,
Kaan
Kaan Özgen 11/11/2009 10:26 AM
Thank you Kaan Özgen.

Yes, You are correct and this idea is true.
Mohsen 11/15/2009 11:52 AM
You'r welcome, here is how I play with roles and stuff:


        Dim role As String = ""
        Dim userName As String = ""
        If Request.IsAuthenticated = True Then
            userName = User.Identity.Name
            If User.IsInRole("A") Then
                role = "A"
            ElseIf User.IsInRole("Admin") Then
                role = "Admin"
            ElseIf User.IsInRole("Customer") Then
                role = "Customer"
            End If
        Else
            role = "Guest"
            userName = "Guest"
        End If

        Dim controlName As String
        Dim controlPath As String
        Dim controlToLoad As Control

                Dim ctrlFileVista As New FileVistaControl
                Dim RootFolder As FileVistaRootFolder
                ctrlFileVista = ctrlFileVista.LoadControl("~\FileManager\FileVistaControl\filevista.ascx")
                ctrlFileVista.LicenseKey = "temp"
                ctrlFileVista.Style = "width: 100%; height:400px; position:relative; left:10em;"
                Dim userFolderName As String
                Dim userFolderPath As String
                If role = "A" Then
                    userFolderName = userName
                    userFolderPath = "~/FileManager/ARoot/" & userName
                    RootFolder = New FileVistaRootFolder(userFolderName, userFolderPath)
                    RootFolder.Permissions = FileVistaPermissions.Full
                    ctrlFileVista.RootFolders.Add(RootFolder)

                    RootFolder = New FileVistaRootFolder("A", "~/FileManager/ARoot/A")
                    RootFolder.Permissions = FileVistaPermissions.Full
                    ctrlFileVista.RootFolders.Add(RootFolder)

                    RootFolder = New FileVistaRootFolder("Projects", "~/FileManager/ProjectsRoot")
                    RootFolder.Permissions = FileVistaPermissions.Full
                    ctrlFileVista.RootFolders.Add(RootFolder)

                    RootFolder = New FileVistaRootFolder("Public", "~/FileManager/Public")
                    RootFolder.Permissions = FileVistaPermissions.Full
                    ctrlFileVista.RootFolders.Add(RootFolder)
                ElseIf role = "Customer" Then
                    userFolderName = userName
                    userFolderPath = "~/FileManager/ProjectsRoot/" & userName
                    RootFolder = New FileVistaRootFolder(userFolderName, userFolderPath)
                    RootFolder.Permissions = FileVistaPermissions.Full
                    ctrlFileVista.RootFolders.Add(RootFolder)

                    RootFolder = New FileVistaRootFolder("Public", "~/FileManager/Public")
                    RootFolder.Permissions = FileVistaPermissions.ReadOnly
                    ctrlFileVista.RootFolders.Add(RootFolder)
                Else
                    RootFolder = New FileVistaRootFolder("Public", "~/FileManager/Public")
                    RootFolder.Permissions = FileVistaPermissions.ReadOnly
                    ctrlFileVista.RootFolders.Add(RootFolder)
                End If

                Me.mainInfo.Controls.Add(ctrlFileVista)

Regards,
Kaan
Kaan Özgen 11/15/2009 12:57 PM