IVSSUser.ProjectRights Property
Gets or sets the project rights of the user to a specific project.
Namespace: Microsoft.VisualStudio.SourceSafe.Interop
Assembly: Microsoft.VisualStudio.SourceSafe.Interop (in microsoft.visualstudio.sourcesafe.interop.dll)
Syntax
'Declaration
Property ProjectRights ( _
<InAttribute> <OptionalAttribute> Optional Project As String = "$/" _
) As Integer
'Usage
Dim instance As IVSSUser
Dim Project As String
Dim value As Integer
value = instance.ProjectRights(Project)
instance.ProjectRights(Project) = value
int ProjectRights [
[OptionalAttribute] [InAttribute] string Project
] { get; set; }
property int ProjectRights [String^] {
int get ([InAttribute] [OptionalAttribute] String^ Project);
void set ([InAttribute] [OptionalAttribute] String^ Project, [InAttribute] int piRightsOut);
}
/** @property */
int get_ProjectRights (/** @attribute InAttribute() */ /** @attribute OptionalAttribute() */ String Project)
/** @property */
void set_ProjectRights (/** @attribute InAttribute() */ /** @attribute OptionalAttribute() */ String Project, /** @attribute InAttribute() */ int piRightsOut)
JScript supports the use of indexed properties, but not the declaration of new ones.
Parameters
- Project
(Optional). A string representing the SourceSafe path of a project for which you get or set project rights. The default is $/ (the root project).
Property Value
The project rights of the user to a specific project.
Remarks
[IDL]
HRESULT ProjectRights([in, defaultvalue("$/")] BSTR Project, [out, retval] long *piRightsOut);
HRESULT ProjectRights([in, defaultvalue("$/")] BSTR Project, [in] long iRightsIn);
For ProjectRights to be enabled, the ProjectRightsEnabled property of the database object must be set to true. The ProjectRights of Admin cannot be changed.
All users in the SourceSafe database have specific project rights assigned to them by Admin. That assignment propagates down the project list until another assignment is reached. For example, you assign (VSSRIGHTS_ADDRENREM) (Add) rights to the User1 in $/, the root project. If no explicit assignment is made in $/Test project, the User1 is automatically assigned the same rights as in the parent project, $/. However, if in $/Test/Samples you assign VSSRIGHTS_READ (Read-Only) rights to the User1, this action blocks the earlier assignment in $/Test from propagating down the tree. Consequently, the User1 has Read-Only rights in $/Test/Samples and any projects under it. If the project rights are inherited from the parent project, the ProjectRights property includes the VSSRIGHTS_INHERITED flag.
When you first add a user, that user is given rights in the root project based on the DefaultProjectRights of the database object.
Example
The following example demonstrates how to use the ProjectRights property to set and get the project rights of a user for the project, $/A.
using System;
using Microsoft.VisualStudio.SourceSafe.Interop;
public class IVSSTest
{
private static string GetUsername()
{
Console.Write("Enter Username: ");
return Console.ReadLine();
}
private static string GetPassword()
{
Console.Write("Enter Password: ");
return Console.ReadLine();
}
public static void Main()
{
// Create a VSSDatabase object.
IVSSDatabase vssDatabase = new VSSDatabase();
// Only SourceSafe Admin can access ProjectRights.
Console.WriteLine("Admin login");
vssDatabase.Open(@"C:\VSSTestDB\srcsafe.ini",
GetUsername(), GetPassword());
IVSSUser vssUser = vssDatabase.get_User("Guest");
vssUser.set_ProjectRights("$/A", (int)VSSRights.VSSRIGHTS_READ);
Console.WriteLine("Project Rights of user {0} for project $/A: {1}",
vssUser.Name,
(VSSRights)vssUser.get_ProjectRights("$/A"));
vssUser.set_ProjectRights("$/A", (int)VSSRights.VSSRIGHTS_ALL);
Console.WriteLine("Project Rights of user {0} for project $/A: {1}",
vssUser.Name,
(VSSRights)vssUser.get_ProjectRights("$/A"));
}
}
Output:
Admin login
Enter Username:
Enter Password:
Project Rights of user Guest for project $/A: VSSRIGHTS_READ
Project Rights of user Guest for project $/A: VSSRIGHTS_ALL
Imports System
Imports Microsoft.VisualStudio.SourceSafe.Interop
Module IVSSTest
Function GetUsername() As String
Console.Write("Enter Username: ")
Return Console.ReadLine()
End Function
Function GetPassword() As String
Console.Write("Enter Password: ")
Return Console.ReadLine()
End Function
Public Sub Main()
' Create a VSSDatabase object.
Dim vssDatabase As IVSSDatabase = New VSSDatabase
' Only SourceSafe Admin can access ProjectRights.
vssDatabase.Open("C:\VSSTestDB\srcsafe.ini", _
GetUsername(), GetPassword())
Dim vssUser As IVSSUser = vssDatabase.User("Guest")
vssUser.ProjectRights("$/A") = Fix(VSSRights.VSSRIGHTS_READ)
Console.WriteLine("Project Rights of user {0} for project $/A: {1}", _
vssUser.Name, CType(vssUser.ProjectRights("$/A"), _
VSSRights))
vssUser.ProjectRights("$/A") = Fix(VSSRights.VSSRIGHTS_ALL)
Console.WriteLine("Project Rights of user {0} for project $/A: {1}", _
vssUser.Name, CType(vssUser.ProjectRights("$/A"), _
VSSRights))
End Sub
End Module
Output:
Admin login
Enter Username:
Enter Password:
Project Rights of user Guest for project $/A: VSSRIGHTS_READ
Project Rights of user Guest for project $/A: VSSRIGHTS_ALL
See Also
Reference
IVSSUser Interface
IVSSUser Members
Microsoft.VisualStudio.SourceSafe.Interop Namespace