How to get a list of the connected vault workgroup users

How to get a list of the connected vault workgroup users

Anonymous
Not applicable
1,455 Views
2 Replies
Message 1 of 3

How to get a list of the connected vault workgroup users

Anonymous
Not applicable

I've searched all over and could not find the answer I needed. So all help is appreciated.

 

In the vault workgroup from Autodesk, there are licenses divided over users that use the vault workgroup. But when all licenses are used, it is difficult to know who is still logged in that doesn’t use the vault at the moment.

 

So to solve this problem I would like to write a program that gives me a list of connected users. So far I found some code to show me all users from the vault workgroup, but that information is useless because I know all user accounts. I just need the currently connected users.

 

Code I’ve got so far:

 

public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
    }

    private void PrintUsers(object sender, RoutedEventArgs e)
    {
        MyVault.AdminSample.PrintUserInfo();
    }
}

class MyVaultServiceManager : System.IDisposable
{
    // We will incapsulate the WebServiceManager here.
    // The WebServiceManager will be used for our Vault server calls.
    private WebServiceManager _svcManager = null;
    public WebServiceManager Services
    { get { return _svcManager; } }

    public enum Mode { ReadOnly, ReadWrite };

    // Preventing usage of the default constructor - made it private
    private MyVaultServiceManager() { }

    // Constructor.
    // Parameter: - Log in as read-only, which doesn't consume 
    //              a license.
    //===============================================================
    public MyVaultServiceManager(Mode i_ReadWriteMode)
    {
        UserPasswordCredentials login = new UserPasswordCredentials(
                             "localhost", "Vault", "Administrator", "",
                             (i_ReadWriteMode == Mode.ReadOnly));
        // Yeah, we shouldn't hardcode the credentials here,
        // but this is just a sample        _svcManager = new WebServiceManager(login);
    }


    void System.IDisposable.Dispose()
    {        _svcManager.Dispose();
    }
}

class AdminSample
{
    // Lists all the users along with their roles and the vaults they 
    //   have access to.
    //===============================================================
    public static void PrintUserInfo()
    {
        try
        {            using (MyVaultServiceManager mgr = new MyVaultServiceManager(
                                    MyVaultServiceManager.Mode.ReadOnly))
            {
                // The GetAllUsers method provides all the users' info
                //-----------------------------------------------------
                User[] users = mgr.Services.AdminService.GetAllUsers();

                TextWriter tmp = Console.Out;
                FileStream filestream = new FileStream("Vault_Users.txt", FileMode.Create);
                var streamwriter = new StreamWriter(filestream);                streamwriter.AutoFlush = true;
                Console.SetOut(streamwriter);

                foreach (User user in users)
                {
                    UserInfo userInfo = mgr.Services.AdminService.GetUserInfoByUserId(user.Id);

                    Console.WriteLine(user.Name);

                    if (userInfo.Roles != null && userInfo.Roles.Length > 0)
                    {
                        Console.WriteLine("   Roles:");
                        foreach (Role role in userInfo.Roles)
                        {
                            Console.WriteLine("     ID: " + role.Id + " | Name: " + role.Name);
                        }
                    }

                    if (userInfo.Vaults != null && userInfo.Vaults.Length > 0)
                    {
                        Console.WriteLine("   Vaults:");
                        foreach (KnowledgeVault vault in userInfo.Vaults)
                        {
                            Console.WriteLine("     ID: " + vault.Id + " | Name: " + vault.Name);
                        }
                    }
                    Console.WriteLine("");
                }

                Console.SetOut(tmp);                streamwriter.Close();                filestream.Close();
                MessageBox.Show("Done!", "Completed!");

            } // using
        }
        catch (System.Exception e)
        {
            MessageBox.Show(e.Message);
        }
    } // PrintUserInfo()
}
0 Likes
Accepted solutions (2)
1,456 Views
2 Replies
Replies (2)
Message 2 of 3

minkd
Alumni
Alumni
Accepted solution

There is no API for obtaining information about current "connections".

 

However, as licenses are acquired and released, this information is logged to the AVFSlog on each site.  I believe a number of folks have written parsers to extract this information from those logs with varying degrees of success.

 

-Dave

 



Dave Mink
Fusion Lifecycle
Autodesk, Inc.
0 Likes
Message 3 of 3

Anonymous
Not applicable
Accepted solution

Thx. This helped me out a lot.

 

Program that reads Log File

0 Likes