Try below code:
Public tdc As TDAPIOLELib.TDConnection
Sub addUserGroupToAllProjects()
Dim proj As String
Dim CustGroup As TDAPIOLELib.CustomizationUsersGroup
Const domain = "DEFAULT"
connnect_qc()
For Each proj In tdc.ProjectsListEx(domain)
tdc.Connect(domain, proj)
If Err.Description <> "Failed to Connect Project" Then
If tdc.ProjectConnected = True Then
AddProjectUser("user", "Group")
tdc.Customization.Load()
tdc.Customization.Users.AddUser(NewProjectUser)
' Add the new user to a user group.
CustUsersGroups = tdc.Customization.UsersGroups
'addToUserGroup is a group name, for example "QATester"
CustGroup = CustUsersGroups.Group(addToUserGroup)
' Add the user.
CustGroup.AddUser(NewProjectUser)
tdc.Customization.Commit()
End If
End If
tdc.Disconnect()
Next
tdc.ReleaseConnection()
tdc = Nothing
End Sub
Sub connect_qc()
Dim username, password As String
username = "username"
password = "passwd"
Const qcurl = "http://qualitycenter.domain.com/qcbin/"
tdc = New TDAPIOLELib.TDConnection
tdc.InitConnectionEx(qcurl)
tdc.Login(username, password)
End Sub
No comments:
Post a Comment