IVSSUser.ReadOnly Property 

Gets or sets a value indicating Read-Only rights for the user.

Namespace: Microsoft.VisualStudio.SourceSafe.Interop
Assembly: Microsoft.VisualStudio.SourceSafe.Interop (in microsoft.visualstudio.sourcesafe.interop.dll)

Syntax

'Declaration
Property ReadOnly As Boolean
'Usage
Dim instance As IVSSUser
Dim value As Boolean

value = instance.ReadOnly

instance.ReadOnly = value
bool ReadOnly { get; set; }
property bool ReadOnly {
    bool get ();
    void set ([InAttribute] bool pReadOnly);
}
/** @property */
boolean get_ReadOnly ()

/** @property */
void set_ReadOnly (/** @attribute InAttribute() */ boolean pReadOnly)
function get ReadOnly () : boolean

function set ReadOnly (pReadOnly : boolean)

Property Value

true enables Read-Only rights; false disables.

Remarks

[IDL]

HRESULT ReadOnly([out, retval] boolean *pReadOnly);

HRESULT ReadOnly([in] boolean ReadOnly);

Visual SourceSafe provides two levels of security by setting ProjectRights and by enabling ReadOnly rights. When the ReadOnly property is set to true, the user has Read-Only rights to the database regardless of any other rights settings. In other words, the ReadOnly property overrides the ProjectRights property.

Only Admin can access the ReadOnly property. If a user other than Admin attempts to access the ReadOnly property of any other user, the run-time error is generated.

Example

The following example demonstrates how to use the ReadOnly property to enable Read-Only rights of a user for the project, $/A.

using System;
using Microsoft.VisualStudio.SourceSafe.Interop;

public class VSSUserTest
{
    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()
    {
        VSSDatabase vssDatabase = new VSSDatabase();
        // Only SourceSafe Admin can access ProjectRights
        Console.WriteLine("Admin login");
        vssDatabase.Open(@"C:\VSSTestDB\srcsafe.ini", 
                         GetUsername(),  GetPassword());
        // Get User:
        IVSSUser vssUser = vssDatabase.get_User("Guest");
        vssUser.set_ProjectRights("$/A", (int)VSSRights.VSSRIGHTS_READ);
        Console.WriteLine("Project Rights          :   " + 
                          (VSSRights)vssUser.get_ProjectRights("$/A"));
        vssUser.RemoveProjectRights("$/A");
        // '$/A' inherits Project Rights of '$/'
        Console.WriteLine("Project Rights          :   " + 
                          (VSSRights)vssUser.get_ProjectRights("$/A"));
        vssUser.set_ProjectRights("$/A", (int)VSSRights.VSSRIGHTS_ALL);
        Console.WriteLine("Project Rights          :   " + 
                          (VSSRights)vssUser.get_ProjectRights("$/A"));
        // Enable ReadOnly rights        
        vssUser.ReadOnly = true;
        Console.WriteLine("Read Only               :   " + vssUser.ReadOnly);
        vssUser.ReadOnly = false;
        Console.WriteLine("Read Only               :   " + vssUser.ReadOnly);

        Console.WriteLine("\n\n\nEnum of VSSRights:");
        Console.WriteLine("VSSRights.VSSRIGHTS_READ      = " + 
                          (int)VSSRights.VSSRIGHTS_READ);
        Console.WriteLine("VSSRights.VSSRIGHTS_CHKUPD    = " + 
                          (int)VSSRights.VSSRIGHTS_CHKUPD);
        Console.WriteLine("VSSRights.VSSRIGHTS_ADDRENREM = " + 
                          (int)VSSRights.VSSRIGHTS_ADDRENREM);
        Console.WriteLine("VSSRights.VSSRIGHTS_DESTROY   = " + 
                          (int)VSSRights.VSSRIGHTS_DESTROY);
        Console.WriteLine("VSSRights.VSSRIGHTS_ALL       = " + 
                          (int)VSSRights.VSSRIGHTS_ALL);
        Console.WriteLine("VSSRights.VSSRIGHTS_INHERITED = " + 
                          (int)VSSRights.VSSRIGHTS_INHERITED);
        Console.WriteLine("\n\n");
    }
}

Output:

Admin login
Enter Username: 
Enter Password: 
Project Rights          :   VSSRIGHTS_READ
Project Rights          :   31 (VSSRIGHTS_ALL + VSSRIGHTS_INHERITED)
Project Rights          :   VSSRIGHTS_ALL
Read Only               :   True
Read Only               :   False

Enum of VSSRights:
VSSRights.VSSRIGHTS_READ      = 1
VSSRights.VSSRIGHTS_CHKUPD    = 2
VSSRights.VSSRIGHTS_ADDRENREM = 4
VSSRights.VSSRIGHTS_DESTROY   = 8
VSSRights.VSSRIGHTS_ALL       = 15
VSSRights.VSSRIGHTS_INHERITED = 16

See Also

Reference

IVSSUser Interface
IVSSUser Members
Microsoft.VisualStudio.SourceSafe.Interop Namespace