Vault Customization

Reply
Valued Contributor kbo
Valued Contributor
kbo
Posts: 84
Registered: ‎08-18-2010
Message 1 of 6 (535 Views)
Accepted Solution

Here is a working Windows login to vault but how do i ensure a right logout

535 Views, 5 Replies
01-23-2012 11:54 AM

I played around with the listfiles example in the Vault sdk and struggled, like a lot of others i think. With getting the windows login to work. i made it at an inventor addin and here is what worked for me. but how do i ensure a proper logout? any help appreciated

 

regards.

 

kent boettger

 

 Private Const HOST As String = "srv-pdm" '"localhost"

    Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click
        'RunCommandNormalLogin(HOST)
        RunCommandWinLogin(HOST)
        
    End Sub
    Public Sub RunCommandWinLogin(ByVal serverName As String)

        'Login with Windows User login
        Dim winAuthSvc As WinAuthService = New WinAuthService()

        winAuthSvc.Url = "http://" + serverName + "/AutodeskDM/Services/WinAuth/WinAuthService.asmx"
        winAuthSvc.UseDefaultCredentials = True
        winAuthSvc.SecurityHeaderValue = New WinAuthSvc.SecurityHeader()
        winAuthSvc.SignIn("Vault")

        Dim docSrv As DocumentService = New DocumentService()
        docSrv.SecurityHeaderValue = New Autodesk.Connectivity.WebServices.DocumentSvc.SecurityHeader()
        docSrv.SecurityHeaderValue.UserId = WinAuthSvc.SecurityHeaderValue.UserId
        docSrv.SecurityHeaderValue.Ticket = WinAuthSvc.SecurityHeaderValue.Ticket
        docSrv.Url = "http://" + serverName + "/AutodeskDM/Services/DocumentService.asmx"

        Dim login As WinAuthCredentials = New WinAuthCredentials(serverName, "Vault")

        Using serviceManager As New WebServiceManager(login)
            Try
                Dim root As Folder = docSrv.GetFolderRoot()

                Me.m_listBox.Items.Clear()
                PrintFilesInFolder(root, docSrv)
            Catch ex As Exception
                MessageBox.Show(ex.ToString(), "Error")
            End Try
        End Using

    End Sub

 

Employee
Redmond.D
Posts: 796
Registered: ‎12-12-2006
Message 2 of 6 (518 Views)

Re: Here is a working Windows login to vault but how do i ensure a right logout

01-27-2012 05:09 AM in reply to: kbo

The WebServiceManager will log out for you when the USING block exists.  This article explains things more.

 

I apologize.  The VB version of VaultList could have been written better.  In fact, you can remove about half the code in your RunCommandWinLogin.  Everything before "Dim login as WinAuthCredentials" can be removed.

 

For the next SDK release, we cleaned it up a bit to look like this...

 

    Private Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button1.Click
        ListAllFiles()
    End Sub

    ''' <summary>
    ''' This function lists all the files in the Vault and displays them in the form's ListBox.
    ''' </summary>
    Public Sub ListAllFiles()

        ' Set up the login credentials for Vault.
        ' For demonstration purposes, the information is hard-coded.
        Dim login As New UserPasswordCredentials("localhost", "Vault", "Administrator", "", _
            True)  ' log in as read-only, which doesn't consume a license

        ' Create the WebServiceManager which can be used for all Vault Server calls.
        ' Putting the manager in a using block insures that it logs out when we are done.
        Using serviceManager As New WebServiceManager(login)
            Try
                ' Start at the root Folder.
                Dim root As Folder = serviceManager.DocumentService.GetFolderRoot()

                Me.m_listBox.Items.Clear()

                ' Call a function which prints all files in a Folder and sub-Folders.
                PrintFilesInFolder(root, serviceManager)
            Catch ex As Exception
                MessageBox.Show(ex.ToString(), "Error")
                Return
            End Try
        End Using
    End Sub

 



Doug Redmond
Software Engineer
Autodesk, Inc.
http://justonesandzeros.typepad.com/

Contributor
larry.daubenspeck
Posts: 13
Registered: ‎08-30-2007
Message 3 of 6 (435 Views)

Re: Here is a working Windows login to vault but how do i ensure a right logout

05-29-2012 11:55 AM in reply to: Redmond.D

Hi Doug,

 

I'm trying to search through these forums for problems similar to mine and found this one.  Do the changes you made to Kent's original code still use the Windows login credentials?  What about the Windows Authorization Service?  Does it not get used anymore?  You commented that you hard-coded for demonstration purposes, but now I'm really confused.  Does your solution maintain the original login intent?

 

Larry Daubenspeck

Larry Daubenspeck
Software Programmer
Draper, Inc.
Employee
Daniel.Dulzo
Posts: 61
Registered: ‎05-25-2011
Message 4 of 6 (427 Views)

Re: Here is a working Windows login to vault but how do i ensure a right logout

05-30-2012 07:52 AM in reply to: larry.daubenspeck

Hi Larry,

 

Doug's code above doesn't use windows authentication, but demonstrates how to use the WebServiceManager to manage logging in and out of a Vault for you. The WinAuthService is still used, but if you use the WebServiceManager, it handles everything for you. You can give the WebServiceManager different types of credentials in its constructor if you would to authenticate in different ways. If you're trying to log in to a vault using windows authentication, you should construct the WebServiceManager using the WinAuthCredentials class. An example of its usage can be seen below:

 

using(WebServiceManager wsManager = new WebServiceManager(new WinAuthCredentials("localhost", "Vault"))

{

     // use the wsManager here to make sever calls to vault

     ...

}

 

For more information, I recommend consulting the article that Doug points out in his post above.



Daniel Dulzo
Software Engineer
Autodesk, Inc.
Distinguished Contributor
MaxU77
Posts: 204
Registered: ‎04-25-2008
Message 5 of 6 (363 Views)

Re: Here is a working Windows login to vault but how do i ensure a right logout

08-15-2012 11:54 PM in reply to: Daniel.Dulzo

Maybe a bit offtopic, but what about PowerShell? The hardcoded variant is:

 

Add-Type -Path "C:\Program Files (x86)\Autodesk\Autodesk Vault 2012 SDK\bin\Autodesk.Connectivity.WebServicesTools.dll" $cred = New-Object Autodesk.Connectivity.WebServicesTools.UserPasswordCredentials ("<TODOservername>","<TODOdatabase>","<TODOaccount>","<TODOpassword>",$true)

$webSvc = New-Object Autodesk.Connectivity.WebServicesTools.WebServiceManager ($cred)

 

Could you plese help to modfy it to WinAuth variant?

MaxU77,
AI2011 Certified Associate
(Soft: PDSU2012, VP2012&VP2013)
Employee
Redmond.D
Posts: 796
Registered: ‎12-12-2006
Message 6 of 6 (360 Views)

Re: Here is a working Windows login to vault but how do i ensure a right logout

08-16-2012 06:38 AM in reply to: MaxU77

If you can't use a USING block, you can call Dispose() when you are done with the WebServiceManager.  The Dispose will take care of the logout.

 

Example:  $webSvc.Dispose()



Doug Redmond
Software Engineer
Autodesk, Inc.
http://justonesandzeros.typepad.com/

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community