TeamInfoCenter

 
Home Products Collaborative Apps Examples and Ideas About Us Feedback

How To - Get the Accounts and Identities using Groove Web Services

In this example you will want to get the current accounts and identities for Groove on the current PC. The accounts/identities will be displayed in a TreeView control named tvAccounts. Here is what it looks like:

  First, we want to set up a class to hold the account information the application will be working with.

Public Class AccountData
    Public AccountURL As String
    Public ContactURL As String
    Public AccountIdentityURL As String
    Public IdentitySpaceURL As String
    Public Name As String
End Class

Using Groove Web Services you will want to request Groove to return all the current accounts and information about those accounts. When you request account information from Groove using GWS you need to give it two pieces of information: the current Groove Nonce, and the Groove URL for account information.

The Nonce is changed every time Groove is started. See this page for how to get the current Nonce.

 The Groove Account URL is made up of the Groove Host and the string "/GWS/Groove/1.0/Accounts/". See this page for how to create the Groove Host string.

Dim svc As New gwsAccounts.GrooveAccounts()
svc.GrooveHeaderValue = New gwsAccounts.GrooveHeader()

svc.GrooveHeaderValue.GrooveNonce
 = gwsNonce()
svc.Url = gwsHost & "/GWS/Groove/1.0/Accounts/"
 

Then you send the request for the account information and you will receive an array of account information. You may want to wrap this in a try/catch structure to handle any exceptions.

accounts = svc.Read

Once you have the array of accounts you will want to go through each account and store the information in your application and display these accounts in the user interface. Each account can have one or more identities in that account. All of the shared spaces are associated with an identity. So an accountData object will be created for each identity in an account. The accountData object holds the needed information. Then a tree node is created for the account TreeView and the node text is set to the identity name, with the node tag holding the accountData object. The node is then added to the TreeView.

        'Cache the account/identity information in the application
        For Each act In accounts
            'An account can have multiple identities
            Dim anIdentity As gwsAccounts.Identity
            For Each anIdentity In act.Identities
                Application.DoEvents()

                'Cache this account/identity info in an object
                Dim account As AccountData = New AccountData()
                account.AccountURL = act.URI
                account.ContactURL = act.Contacts
                account.Name = anIdentity.Name
                account.AccountIdentityURL = anIdentity.URI
                account.IdentitySpaceURL = anIdentity.Spaces

                'This accountNode object is used to hold the account info in the UI
                Dim accountNode As TreeNode
                accountNode = tvAccounts.Nodes.Add(anIdentity.Name)
                accountNode.Tag = account
            Next
        Next


The completed method

    Private Sub GetAccounts()
        tvAccounts.Nodes.Clear()
        Dim accounts() As gwsAccounts.Account
        Dim act As gwsAccounts.Account
        Dim svc As New gwsAccounts.GrooveAccounts()

        svc.GrooveHeaderValue = New gwsAccounts.GrooveHeader()
        ' local invocation requires this token
        svc.GrooveHeaderValue.GrooveNonce = gwsNonce()
        svc.Url = gwsHost & "/GWS/Groove/1.0/Accounts/"

        Application.DoEvents()
        Try
            accounts = svc.Read
        Catch ex As Exception
            MessageBox.Show _
                (
"There is a problem in reading the account information.",_
                
" Sub GetAccounts()")
        End Try

        'Cache the account/identity information in the application
        For Each act In accounts
            'An account can have multiple identities
            Dim anIdentity As gwsAccounts.Identity
            For Each anIdentity In act.Identities
                Application.DoEvents()

                'Cache this account/identity info in an object
                Dim account As AccountData = New AccountData()
                account.AccountURL = act.URI
                account.ContactURL = act.Contacts
                account.Name = anIdentity.Name
                account.AccountIdentityURL = anIdentity.URI
                account.IdentitySpaceURL = anIdentity.Spaces

                'This accountNode object is used to hold the account info in the UI
                Dim accountNode As TreeNode
                accountNode = tvAccounts.Nodes.Add(anIdentity.Name)
                accountNode.Tag = account
            Next
        Next
    End Sub


Groove Account information object

Property Description Type
URI The Unique identifier for this account String
Contacts The URI for accessing contact information associated with this account String
Name The name of the account String
Identities An array of Groove Identities in this account Array of Groove Identities

Groove Identity Information object

Property Description Type
URI The Unique identifier for this identity String
Spaces The URI for accessing information about the shared spaces associated with this identity String
Name The name of the identity String

Copyright 2003-2007 JWG Solutions, All Rights Reserved.