Export (0) Print
Expand All

IVSSDatabase.DefaultProjectRights Property 

Visual Studio 2005

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)

int DefaultProjectRights { get; set; }
/** @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.

[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.

NoteNote

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.

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

Community Additions

ADD
Show:
© 2014 Microsoft