Discussion Forum for StarTeam Users


Re: UserAccount


[ Follow Ups ] [ Post Followup ] [ Discussion Forum for StarTeam Users]

Posted by Tommie Mademark on February 26, 2001 at 14:41:51:

In Reply to: UserAccount posted by Martin on February 26, 2001 at 11:18:11:

: Maybe you'll find this question very silly, but I can't get through. How to initialize UserAccount object to be able to access all it's properties? I mean I'm able to create it, but I can't see any properties ie. email, name, logonname etc. I want to list all users in ST server with their emails. I'm using Active server pages.

Here is an example written in VB Script that might help you.

/Tommie

' ---------------------------------------------------------------------------
' This example shows integration between StarTeam
' and a third-party Windows application.
'
' We create a word document that contains contact
' information for all StarTeam users in a repository.
'
' Usage: ExportUsers [ServerAddress [ServerPort [FileName] ] ]
'
' ServerAddress: Address of StarTeam Server.
' Default is localhost.
'
' ServerPort: Port number of StarTeam Server.
' Default is 49201.
'
' FileName: Name of MS Word file to be created.
' Default is "UserList.doc" in "My Documents" folder.
' ---------------------------------------------------------------------------

Dim strServer, nPort, strFileName
strAddress = "Enter_the_name_of_your_server_here"
nPort = 49201
strFileName = "UserList"

If (WScript.Arguments.Count > 0) Then
strAddress = WScript.Arguments(0)
End If

If (WScript.Arguments.Count > 1) Then
nPort = CInt(WScript.Arguments(1))
End If

If (WScript.Arguments.Count > 2) Then
strFileName = WScript.Arguments(2)
End If

Dim strUser, strPassword
strUser = "Administrator"
strPassword = "Administrator"

' Create a StarTeam Server object.
Dim StServerFactory, StServer
Set StServerFactory = WScript.CreateObject("StarTeam.StServerFactory")
Set StServer = StServerFactory.Create(strAddress, nPort)

' Establish a connection to the server.
StServer.connect

' Logon as the given user.
StServer.logOn strUser, strPassword

' Run Microsoft Word.
Dim MSWord
Set MSWord = WScript.CreateObject("Word.Application")
MSWord.Visible = true
MSWord.Activate

' Create a new Word document.
Dim MSWordDoc
Set MSWordDoc = MSWord.Documents.Add
MSWordDoc.Activate

' Constants from the MS Word type library.
' In a future version of WScript, you'll be able to access these directly.
wdToggle = 9999998

' Subroutine to write contact information for one user
' to the currently active Word document.
Sub WriteUser(ByVal strUser, ByVal strEmail, ByVal strPhone)

If (strEmail = "") Then
strEmail = "Unavailable"
End If

If (strPhone = "") Then
strPhone = "Unavailable"
End If

MSWord.Selection.Font.Bold = wdToggle
MSWord.Selection.Font.Size = 14
MSWord.Selection.TypeText strUser
MSWord.Selection.TypeParagraph
MSWord.Selection.Font.Size = 12
MSWord.Selection.Font.Bold = wdToggle
MSWord.Selection.TypeText "Email: " + strEmail
MSWord.Selection.TypeParagraph
MSWord.Selection.TypeText "Phone: " + strPhone
MSWord.Selection.TypeParagraph
MSWord.Selection.TypeParagraph
End Sub

' For each user account on the StarTeam Server ...
Dim StUser
For Each StUser in StServer.Administration.UserAccounts

' Write this user's contact info to the Word document.
WriteUser StUser.Name, StUser.EmailAddress, StUser.PhoneNumber

Next

' Disconnect from the server.
StServer.disconnect

' If a filename was provided, save the document.
If Not (strFileName = "") Then
MSWordDoc.SaveAs strFileName
End If


Follow Ups:



Post a Followup

Name:
E-Mail:

Subject:

Comments:


[ Follow Ups ] [ Post Followup ] [ Discussion Forum for StarTeam Users]