• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Autodesk Vault Customization

    Reply
    Active Contributor kbo
    Active Contributor
    kbo
    Posts: 32
    Registered: 08-18-2010

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

    96 Views, 1 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
    Posts: 414
    Registered: 12-12-2006

    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/