Client API help please...

If you are having a problem using Vault, post a message here.

Moderator: SourceGear

Post Reply
DarrenS
Posts: 49
Joined: Wed Mar 17, 2004 4:56 pm
Location: Inglewood, CA

Client API help please...

Post by DarrenS » Tue May 04, 2004 11:22 am

I'm trying to produce a report showing a list of users, default rights & folder rights for all users in our database.

I downloaded the client API stuff and started modifying the DoListUsers routine - however, when I try this:

Code: Select all

foreach ( VaultClientNetLib.AdminService.VaultFolderRightsItem anItem in u.FolderRights )
I never see any folder rights, even if I explicitly assign some in the admin tool. The default rights show up just fine.

More generally, is there any documentation on the other Vault assemblies than VaultClientOperationsLib ? The command line client uses other libraries like VaultClientNetLib and VaultLib, but I didn't see any .chm for those.

OK, if I may slip in another question and get a "two-fer" here...
I'm also trying (elsewhere) to decode the "action" parameter in the history items. However, the switch-case is failing to nail the item - it always hits the "default" case. Any ideas?!

Code: Select all

// item = a valid VaultHistoryItem 
switch (item.HistItemType)
	case VaultHistoryType.Added:
	  // ...
               break;
                        ...
             case default:
                 // this always fires!  
I checked the type of "HistItemType" - it's "byte", just like the members of VaultHistoryType. If I "toString" the .HistItemType I get a seemingly sane value - e.g. 140 decimal, but the corresponding item in the 'switch' doesn't fire (in this case I think it should be VaultHistoryType.Obliterated). Any insight much appreciated.

jeremy_sg
Posts: 1821
Joined: Thu Dec 18, 2003 11:39 am
Location: Sourcegear
Contact:

Post by jeremy_sg » Tue May 04, 2004 12:35 pm

Darren,

There's a sample history query that I wrote at http://support.sourcegear.com/viewtopic.php?t=450 Take a look at that for switching on the history item type.

I need more context for your VaultFolderRightsItem question.

DarrenS
Posts: 49
Joined: Wed Mar 17, 2004 4:56 pm
Location: Inglewood, CA

Post by DarrenS » Tue May 04, 2004 7:13 pm

Jeremy, I modified the Command Line client sample to add access rights information to the "LISTUSERS" command.

Code: Select all

private void DoListUsers()
		{
			VaultClientNetLib.AdminService.VaultUser[] users = null;
			_ci.Connection.ListUsers(ref users);

			_xml.Begin("listusers");
			foreach (VaultClientNetLib.AdminService.VaultUser u in users)
			{
				_xml.Begin("user");
				_xml.AddPair("login", u.Login);
				if ( _args.Verbose )
				{
					_xml.AddPair("email", u.Email);
					_xml.AddPair("active", u.isActive);

					// rights
					_xml.AddPair("defaultRights", DecodeUserRights(u.DefaultRights) );
					_xml.Begin("folderRrights");
					if (u.FolderRights != null)
					{
						foreach ( VaultClientNetLib.AdminService.VaultFolderRightsItem anItem in u.FolderRights )
						{
							_xml.Begin("singleRight");
							_xml.AddPair("folder", anItem.Name);
							_xml.AddPair("right", DecodeUserRights(anItem.FolderRights));
							_xml.End();
						}
					}
					_xml.End();
				}
				_xml.End();
			}
			_xml.End();
		}
The condition "if (u.FolderRights != null)" is always false, even when I explicitly add users rights to a bunch of folders throught he Admin tool.

DarrenS
Posts: 49
Joined: Wed Mar 17, 2004 4:56 pm
Location: Inglewood, CA

Post by DarrenS » Thu May 06, 2004 11:08 am

Bump.

Any ideas guys?

jeremy_sg
Posts: 1821
Joined: Thu Dec 18, 2003 11:39 am
Location: Sourcegear
Contact:

Post by jeremy_sg » Thu May 06, 2004 2:35 pm

There is a simple explanation for this. ListUsers doesn't fill in the folderrights array. Use ListRightsByUser instead. I'll add a bug to correct that oversight or remove that array.

DarrenS
Posts: 49
Joined: Wed Mar 17, 2004 4:56 pm
Location: Inglewood, CA

Post by DarrenS » Thu May 06, 2004 4:28 pm

Thanks Jeremy - that fixed it.

I'm having a different problem now: even when I set the repository associated with the current ClientInstance (_ci), I still get permissions for all repositories - is this the bug that was fixed in the latest release of Vault? (To set the repository, I'm using the FindRepository() method which I think I got from the sample client code no your blog).

jeremy_sg
Posts: 1821
Joined: Thu Dec 18, 2003 11:39 am
Location: Sourcegear
Contact:

Post by jeremy_sg » Fri May 07, 2004 8:26 am

You are right, the listrightsbyuser doesn't limit itself to one repository (that's because we only use it to populate the tab in the admin tool which has all rights assignments for all repositories. Note that each VaultFolderRightsItem has a repid, which you can use to limit the results that you print out.

DarrenS
Posts: 49
Joined: Wed Mar 17, 2004 4:56 pm
Location: Inglewood, CA

Post by DarrenS » Fri May 07, 2004 11:15 am

It works! Thanks!

One more teensy-weensy question: after assigning rights in the Vault client, how do I remove those rights and get back to the default? When I uncheck the RCA boxes for a particular user and folder, in my command line client I still see a FolderRightsItem for that user & folder, but with none of the RCA flags set. How can I get rid of that item entirely?

Post Reply