Community
Vault Customization
Share your knowledge, ask questions, and explore popular Vault API, Data Standard, and VBA topics related to programming, creating add-ins, or working with the Vault API.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Vault 2015 API how to get the user name of logged user.

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
raghulan
2479 Views, 8 Replies

Vault 2015 API how to get the user name of logged user.

I need to get the user who currently logged in to the client.

 

could anyone provide a sample code on this please.

 

I tried to get the security header value but it doesnt work.

Regards,

Raghulan Gowthaman Cert IV TAA, B.E,.
Senior Technical Consultant | Developer - R&D
A2K Technologies Sydney
Web : www.a2ktechnologies.com.au
www.civil3dforum.com | www.e4forums.com
www.zcodia.com.au
www.raghulangowthaman.com
8 REPLIES 8
Message 2 of 9
Redmond.D
in reply to: raghulan

From the Connection object, you can just read the UserName property.



Doug Redmond
Software Engineer
Autodesk, Inc.

Message 3 of 9
raghulan
in reply to: Redmond.D

Just incase if some one needs this.

 

I was using a WPF window and it is different from the samples which are still in winfoms where the static main is manually altered where as in wpf its autogenerated, even editing it manually will not work.

 

Here is the work flow for wpf devs (Check static main in wpf in google to understand how to have ur own static main in wpf)

 

in App.Xamls.cs

 

[STAThread]
        static void Main()
        {
            App app = new App();
            VDF.Vault.Forms.Settings.LoginSettings settings = new VDF.Vault.Forms.Settings.LoginSettings();
            VDF.Vault.Currency.Connections.Connection connection = VDF.Vault.Forms.Library.Login(settings);

            if (connection == null)
                return;

            MainWindow window = new MainWindow(connection);
            app.Run(window);

            VDF.Vault.Library.ConnectionManager.LogOut(connection);
        }

 

In App.g.cs

 VaultWinApp.App app = new VaultWinApp.App();
            app.InitializeComponent();
            app.Run();

 

In mainWindow 

have the following to store the connection and that can be used locally

private VDF.Vault.Currency.Connections.Connection m_connection;

 

Now access the userId, Username and other connection object as follows

m_connection.UserID.ToString()
m_connection.UserName.ToString();

 Hope it helps someone.

 

 

Regards,

Raghulan Gowthaman Cert IV TAA, B.E,.
Senior Technical Consultant | Developer - R&D
A2K Technologies Sydney
Web : www.a2ktechnologies.com.au
www.civil3dforum.com | www.e4forums.com
www.zcodia.com.au
www.raghulangowthaman.com
Message 4 of 9
Maarten65
in reply to: raghulan

Using the connection object to get the user name only works when you are NOT using the windows authentication login.

If using the WA you can use

 

 

dim strUserName As String = Environ("Username")

 

Maarten Weers
Technical Specialist CAD - EMEA
Parker Hannifin
Oldenzaal - The Netherlands
-------------------------------------------------------------------------------------------
Inventor Pro 2019 - Vault Professional 2019 - Windows 10 64 bit -
Message 5 of 9
martinxw
in reply to: Redmond.D

Hello,

 

so you  say, that there is no API to read email logged User?

I'm logged user and I'm not able read my own mail by Vault API???

 

Seriously?

Message 6 of 9
Markus.Koechl
in reply to: martinxw

Please note - this thread has been specific to the connection object's information about the user.
You can get all properties of a user's Vault account info using the "User" object. Starting in Vault 2019 a custom role allows reading this information and can be shared to all users or certain groups.
Hope this clarifies.


Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
Message 7 of 9
UweHandzik
in reply to: martinxw

Hello,
Your get the UserId for Example 


Public Enum eGetUser
    Mail 
    Name 
End Enum
....
Dim allVltUsers As Autodesk.Connectivity.WebServices.User() = Autodesk.Connectivity.WebServices.AdminService.GetAllUsers()


For Each myUser As ACW.User In allVltUsers
    If myUser.Id.ToString = cUserId Then
        Select Case eArt
              Case eGetUser.Mail : Return myUser.Email
              Case eGetUser.Name : Return myUser.Name
       End Select
End If
Next

 

So you can get any Information from the User ... 

 

 

Message 8 of 9
martinxw
in reply to: UweHandzik

Ok, but function 

public User[] GetAllUsers()

has 

Required Permissions

AdminUserRead
Anyone logged user has this permission?
Message 9 of 9
martinxw
in reply to: UweHandzik

I think, the solution is use function 

public User GetUserByUserId( 
   System.long userId
)

 

Required Permissions

None if the logged in user's Id is entered. Otherwise AdminUserRead is required.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report