Page 1 of 1

Get Authorized Repositories and Folders for a given User

Posted: Mon Apr 27, 2015 12:42 pm
by ejhansen71
Hi Beth - I'm back again for another difficult question.

I'm logged in as administrator on this GUI tool I built using Visual Studio and coding in C#.

I want to find out what Repositories and Folders a user is authorized to use. So I need to pass the server a username "ehansen" and have returned the Repositories the user has access to and then find out which folders under that Repository (root folders only...anything directly under "$/") the user has access to.

Can you provide the proper classes/methods to use and perhaps an example?

Re: Get Authorized Repositories and Folders for a given User

Posted: Mon Apr 27, 2015 4:10 pm
by Beth
I moved this to the Development Forum since it relates to this.

I don't think you can get a listing of user rights from the API. I need to do a little more digging to see if I can come up with anything. I could maybe get a SQL query if that would help.

Re: Get Authorized Repositories and Folders for a given User

Posted: Tue Apr 28, 2015 10:43 am
by ejhansen71
A SQL query is better than nothing.

In the standard Vault GUI, When a user has access to only 1 repository (we have 6 totals) and he logs in, only the repository he has access to appears in the Repository selection box. This is what we want on our GUI as well.

In addition, once the repository is open, we want only the folders the user has access to to appear and suppress the rest. Currently your Vault GUI, while only allowing the Repositories they have access to to be selected from, still show all of the possible folders under that repository even if the user has no access to them..

Re: Get Authorized Repositories and Folders for a given User

Posted: Tue Apr 28, 2015 1:44 pm
by Beth
When the user logs in, Vault should refuse to return anything to which the user doesn't have access. You shouldn't need to check the security yourself.

Re: Get Authorized Repositories and Folders for a given User

Posted: Wed Apr 29, 2015 1:55 pm
by ejhansen71
I am doing this in a Windows form via C# and VisualStudio
Two Questions.
Question 1 : Return a list Top Level Folders from a given repository.

I started with getting the repository the User has permission to access. I was able to do that with the following code:

Code: Select all

 VaultRepositoryInfo[] vri = ServerOperations.ProcessCommandListRepositories();
                List<string> repos = null;
                foreach ( VaultRepositoryInfo vrio in vri )
                {
                        repos.Add(vrio.RepName);
                        Console.Writeline(vrio.RepName);
                }
This collected and then wrote out to the Console all of the repositories the user has access to. So far - so good.

Now I want to list the folders inside the Repository. A full list is ok - but even better would be only the top level folders the user has access to.

We call each of the top level folders in a repository "Projects" and it is only the top level "Projects" I wish to list... preferably just the ones they have access to. In your GUI, you limit the repositories, but not the folders. So in your GUI, if I had access to repository AAA and there were 7 folders but I was only granted access to repository AAA folder 3 I would still see repository AAA and all folders 1-7. Really, I would prefer to ONLY see repository AAA and folder 3. When using

Code: Select all

ServerOperations.ProcessCommandListFolder("[b][color=#FF4000]????[/color][/b]", true).Folders;
what is the default folder path for a repository so I can list all the top level folders? Is it "$" or "$/"...or am I using the wrong method entirely?

Questions
1a. How do I get a list of top level folders from a repository?
1b. Can I limit the list of top level folders to only the ones the user has permission to access? If so, how?

Question 2: List Repositories for a different user.

I am logged in as administrator AAA. I have full access to all repositories and all top level folders and everything else available in Vault.

a. What if I want to pass a different username and get the repositories for that user? Can I do that without logging in as that user? Say I have a listbox of users, I select one and I want to see the repositories they have permission to see and the folders under it. Can I pass the AD username and get access to it?

Code: Select all

 ServerOperations.client.LoginOptions.User = GlobalUser;
                ServerOperations.client.LoginOptions.Password = GlobalPassword;
                ServerOperations.Login(); 
                VaultRepositoryInfo[] vri = ServerOperations.ProcessCommandListRepositories();

// Switch user code here
I can get my own userid with this bit of code:

Code: Select all

System.DirectoryServices.AccountManagement.UserPrincipal.Current.SamAccountName;
But I don't know how to switch the Vault User to that login name. Is it possible?

Re: Get Authorized Repositories and Folders for a given User

Posted: Fri May 01, 2015 1:34 pm
by Beth
Are you possibly trying to recreate the Repository Access Report? Do you know that we have that in the web client?

Or one thing you could try is to make a web request to the Repository Access Report and look at look into what it returns for you.