Share via


IVSSUser.RemoveProjectRights Method 

Removes the ProjectRights for a specific project from the user.

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

Syntax

'Declaration
Sub RemoveProjectRights ( _
    <InAttribute> Project As String _
)
'Usage
Dim instance As IVSSUser
Dim Project As String

instance.RemoveProjectRights(Project)
void RemoveProjectRights (
    [InAttribute] string Project
)
void RemoveProjectRights (
    [InAttribute] String^ Project
)
void RemoveProjectRights (
    /** @attribute InAttribute() */ String Project
)
function RemoveProjectRights (
    Project : String
)

Parameters

  • Project
    A string representing the SourceSafe path of a project for which you remove the project rights.

Remarks

[IDL]

HRESULT RemoveProjectRights([in] BSTR Project);

When you remove the ProjectRights of a user, the project inherits ProjectRights from its parent project.

Only Admin can call the RemoveProjectRights method. If a user other than Admin attempts to call the RemoveProjectRights method, a run-time error is generated.

Example

The following example demonstrates how to use the RemoveProjectRights property to remove the project 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