Share via


IVSSDatabase.Users Property 

Gets a reference of the IVSSUsers type to an object representing a collection of all users the SourceSafe database.

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

Syntax

'Declaration
ReadOnly Property Users As IVSSUsers
'Usage
Dim instance As IVSSDatabase
Dim value As IVSSUsers

value = instance.Users
IVSSUsers Users { get; }
property IVSSUsers^ Users {
    IVSSUsers^ get ();
}
/** @property */
IVSSUsers get_Users ()
function get Users () : IVSSUsers

Property Value

A reference of the IVSSUsers type to an object representing a collection of all users within the SourceSafe database.

Remarks

[IDL]

HRESULT Users([out, retval] IVSSUsers **ppIUsers);

The Users property is used to reference a collection of all users within the SourceSafe database. You may add or remove users from this collection by using the AddUser or the Delete methods.

Example

The following example demonstrates how to traverse through the IVSSUsers collection, add and remove IVSSUsers from the collection.

[C#]

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

public class IVSSTest
{
    private static void DisplayUsers(IVSSDatabase vssDatabase)
    {
        Console.Write("Database Users:");
        foreach(IVSSUser vssUser in vssDatabase.Users)
            Console.Write(" {0}", vssUser.Name);
        Console.WriteLine();
    }
 
    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 add a new user.
        Console.WriteLine("Admin login");
        vssDatabase.Open(@"C:\VSSTestDB\srcsafe.ini", 
                         GetUsername(), GetPassword());
        DisplayUsers(vssDatabase);
        // Add new user to the database.
        Console.WriteLine("Add New User");
        IVSSUser vssUser = vssDatabase.AddUser(GetUsername(), 
                                               GetPassword(), false);
        DisplayUsers(vssDatabase);
        // Remove a user from the database
        vssUser.Delete();
        DisplayUsers(vssDatabase);
    }
}

Output:

Admin login

Enter Username:

Enter Password:

Database Users: Admin Guest1 Guest2

Add New User

Enter Username: NewUser

Enter Password:

Database Users: Admin Guest1 Guest2 NewUser

Database Users: Admin Guest1 Guest2 (NewUser is removed)

See Also

Reference

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