Changing repository access for a user that already has acces

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

Moderator: SourceGear

Post Reply
ben
Posts: 18
Joined: Fri Jan 09, 2009 2:35 pm

Changing repository access for a user that already has acces

Post by ben » Thu Jan 29, 2009 9:39 pm

I have given access to a repository for a user using:
AddRepositoryAccess
However, when I try to remove this user's access rights by passing:
VaultRepositoryAccess.None
to the AddRepositoryAccess function, I get a null exception thrown. If the user has not been given access before, no exception is thrown. Is there another way to change a user's access priveleges to a repository once he/she has already been given access?

Ben

shannon

Re: Changing repository access for a user that already has acces

Post by shannon » Thu Jan 29, 2009 9:58 pm

Try using EditUser (also in VaultConnection). Get the VaultUser object - you can use VaultConnection.GetUserList - and modify the AccessInfo field, then pass that to EditUser.

ben
Posts: 18
Joined: Fri Jan 09, 2009 2:35 pm

Re: Changing repository access for a user that already has acces

Post by ben » Fri Jan 30, 2009 9:59 am

I'll give that a try. Thanks.

ben
Posts: 18
Joined: Fri Jan 09, 2009 2:35 pm

Re: Changing repository access for a user that already has acces

Post by ben » Fri Jan 30, 2009 11:51 am

The VaultUser that I'm interested in that is returned from GetUserList is only semi-populated, e.g. VaultAccessInfo is null. When I populate the VaultAccessInfo field and send it to EditUser, I get another null reference exception. Shouldn't VaultUser be completely populated when retrieving it using GetUserList?

shannon

Re: Changing repository access for a user that already has acces

Post by shannon » Fri Jan 30, 2009 2:03 pm

Sorry, missed this method on my first search. Use VaultConnection.RemoveRepositoryAccess

ben
Posts: 18
Joined: Fri Jan 09, 2009 2:35 pm

Re: Changing repository access for a user that already has acces

Post by ben » Sun Feb 01, 2009 6:09 pm

That makes a lot more sense. Thank you.
I tried the method, but I'm getting a null reference exception. I'm connected to the database as an administrator, I can retrieve the repository id and user id and then I call RemoveRepositoryAccess with those parameters but get the null reference:

System.NullReferenceException : Object reference not set to an instance of an object.

Any thoughts on this one?

Ben

shannon

Re: Changing repository access for a user that already has acces

Post by shannon » Sun Feb 01, 2009 10:31 pm

Do you only get an exception with this one user? Is there anything in the server log? (%WINDIR%\Temp\sgvault\sgvault.log on the server machine) Or the client log? (%TEMP%/VaultGUIClient on the client machine)

ben
Posts: 18
Joined: Fri Jan 09, 2009 2:35 pm

Re: Changing repository access for a user that already has acces

Post by ben » Fri Feb 06, 2009 2:40 pm

Finally getting back to this. I'll check those things, thanks...

ben
Posts: 18
Joined: Fri Jan 09, 2009 2:35 pm

Re: Changing repository access for a user that already has acces

Post by ben » Sun Feb 08, 2009 11:04 am

There is nothing unusual in the server log file. I could not locate the client log file. I have a user called "testuser1" that I AddRepositoryAccess'd to one of my repositories. That works fine. Then when I use the RemoveRepositoryAccess function I get the null reference exception. The program connects as admin to perform these functions. I haven't tried removing access of another user. Has anyone used this api call successfully?

Ben

shannon

Re: Changing repository access for a user that already has acces

Post by shannon » Tue Feb 10, 2009 3:23 pm

We make several calls to it in our smoke tests. Can you show me the code you're working with?

Post Reply