Share via


IVSSUser.Name Property 

Gets or sets a string representing a name of the current SourceSafe database user.

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

Syntax

'Declaration
Property Name As String
'Usage
Dim instance As IVSSUser
Dim value As String

value = instance.Name

instance.Name = value
string Name { get; set; }
property String^ Name {
    String^ get ();
    void set ([InAttribute] String^ pName);
}
/** @property */
String get_Name ()

/** @property */
void set_Name (/** @attribute InAttribute() */ String pName)
function get Name () : String

function set Name (pName : String)

Property Value

A string representing a name of the current SourceSafe database user.

Remarks

[IDL]

HRESULT Name([out, retval] BSTR *pName);

HRESULT Name([in] BSTR Name);

Any user can retrieve any user name, but only Admin can set user names. The name, Admin, cannot be changed. If you attempt to change the name, Admin, a run-time error is generated. If a user other than Admin attempts to set the user name, a run-time error is generated.

Example

The following example demonstrates how to use the Name property to display the name of the current SourceSafe database user.

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 for 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 for user {0} for project $/A: {1}", 
                          vssUser.Name, 
                          (VSSRights)vssUser.get_ProjectRights("$/A"));
    }
}

Output:

Admin login

Enter Username:

Enter Password:

Project Rights for user Guest for project $/A: VSSRIGHTS_READ

Project Rights for user Guest for project $/A: VSSRIGHTS_ALL

See Also

Reference

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