Share via


IVSSDatabase.DefaultProjectRights Property 

Gets or sets the default project rights for a new IVSSUser added to the SourceSafe database.

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

Syntax

'Declaration
Property DefaultProjectRights As Integer
'Usage
Dim instance As IVSSDatabase
Dim value As Integer

value = instance.DefaultProjectRights

instance.DefaultProjectRights = value
int DefaultProjectRights { get; set; }
property int DefaultProjectRights {
    int get ();
    void set ([InAttribute] int pRights);
}
/** @property */
int get_DefaultProjectRights ()

/** @property */
void set_DefaultProjectRights (/** @attribute InAttribute() */ int pRights)
function get DefaultProjectRights () : int

function set DefaultProjectRights (pRights : int)

Property Value

The default project rights for a new IVSSUser added to the SourceSafe database.

Remarks

[IDL]

HRESULT DefaultProjectRights([out, retval] long *pRights);

HRESULT DefaultProjectRights([in] long Rights);

The SourceSafe Administrator can add new users to the SourceSafe database. This is done through the AddUser method of the database object. The DefaultProjectRights property is used to set or retrieve the default project rights for a new user added to the SourceSafe database.

The new project rights are used when SourceSafe Explorer and the Admin utility are reopened.

Note

The ProjectRightsEnabled property must be set to true to enable DefaultProjectRights property.

The only valid values for DefaultProjectRights are:

Value

Rights

0

No rights

1

Read rights

3

Read/check out/check in rights

7

Read/check out/check in/add/rename rights

15

Read/check out/check in/add/rename/destroy rights

Each of these values may be created through a combination of predefined constants. For more information on constants, see VSSRights.

Constant

Value

VSSRIGHTS_READ

1

VSSRIGHTS_CHKUPD

2

VSSRIGHTS_ADDRENREM

4

VSSRIGHTS_DESTROY

8

VSSRIGHTS_ALL

15

Example

The following example demonstrates how to use the DefaultProjectRights property to get and set project rights for a new SourceSafe IVSSUser.

[C#]

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 Project Rights.
        vssDatabase.Open(@"C:\VSSTestDB\srcsafe.ini", 
                         GetUsername(), GetPassword());

        //Enable ALL DefaultProjectRights
        vssDatabase.ProjectRightsEnabled = true;
        vssDatabase.DefaultProjectRights = (int)VSSRights.VSSRIGHTS_ALL;

        // Display DefaultProjectRights and ProjectRightsEnabled        
        string rightsOutput = "New User Rights: ";
        switch(vssDatabase.DefaultProjectRights)
        {
            case 0:
                rightsOutput += "No Rights";
                break;
            case (int)VSSRights.VSSRIGHTS_READ:
                rightsOutput += "Read";
                break;
            case (int)VSSRights.VSSRIGHTS_READ + (int)VSSRights.VSSRIGHTS_CHKUPD:
                rightsOutput += "Read/Check Out/Check In";
                break;
            case (int)VSSRights.VSSRIGHTS_READ + 
                 (int)VSSRights.VSSRIGHTS_CHKUPD + 
                 (int)VSSRights.VSSRIGHTS_ADDRENREM:
                rightsOutput += "Read/Check Out/Check In/Add/Rename/Delete";
                break;
            case (int)VSSRights.VSSRIGHTS_ALL:
                rightsOutput += "Read/Check Out/Check " + 
                                "In/Add/Rename/Delete/Destroy";
                break;
            default:        
                throw new Exception("Unknown VSS Database Right");
        }

        Console.WriteLine(rightsOutput);
        Console.WriteLine("Project Rights Enabled: " + 
                          vssDatabase.ProjectRightsEnabled);
    }
}

Output:

New User Rights: Read/Check Out/Check In/Add/Rename/Delete/Destroy

Project Rights Enabled: True

See Also

Reference

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