We help IT Professionals succeed at work.

Com+ applications automate username and password

Medium Priority
213 Views
Last Modified: 2013-11-25
i am trying to create a vb6 application that will update com+ applications username and password. i am using a multiselect listbox to select the application name to update. i have no problem updating one application but problem occur when trying to update more than one. i think my main problem is referencing the application NAME with the application ID    
Comment
Watch Question

Commented:

Public Sub ChangeSecurity(ByVal MTSName As String, ByVal username As String, ByVal Password As String)
    Dim catalog As New MTSAdmin.catalog
    Dim packages As MTSAdmin.CatalogCollection
    Dim package As MTSAdmin.CatalogObject
    
    On Error Resume Next
    Set packages = catalog.GetCollection("Packages")
    packages.Populate
 
    For Each package In packages
        If UCase(package.Value("Name")) = UCase(MTSName) Then
            Exit For
        End If
    Next
    
    If package Is Nothing Then Exit Sub
    package.Value("Identity") = username
    package.Value("Password") = Password
    package.Value("SecurityEnabled") = "Y"
    packages.SaveChanges
    Set package = Nothing
    Set packages = Nothing
    Set catalog = Nothing
End Sub

Open in new window

Author

Commented:
how would i be able to implement this to work with a listbox with multiple applications selected. i want to be able to update more than one application at a time, as i said i have no problem updating one application for a listbox, the problem occur only with multiple applications

Commented:
just pass your applicaton name into the function as MTSName

i assume you list all application on the list box


Dim i As Integer
 
For i = 1 To List1.ListCount
    If List1.Selected(i - 1) Then
        ChangeSecurity List1.List(i - 1), "", ""
    End If
Next

Open in new window

Author

Commented:
this seem to create new applications with the same names as which is selected in the listbox

Commented:
i don't see any line on my code to create a new application.

Post your code otherwise it is hard to know what's wrong

Author

Commented:
Dim catalog As New MTSAdmin.catalog
    Dim packages As MTSAdmin.CatalogCollection
    Dim package As MTSAdmin.CatalogObject
    Dim i As Integer
 
    Set packages = catalog.GetCollection("Packages")
    packages.Populate

For Each package In packages
 
For i = 1 To lstApplications.ListCount
    If lstApplications.Selected(i - 1) = True Then
        MsgBox lstApplications.List(i - 1)
    package.Value("Identity") = "-------"
    package.Value("Password") = "------"
 
       
    End If
Next

    Next
Commented:
For i = 1 To lstApplications.ListCount
    If lstApplications.Selected(i - 1) = True Then
        MsgBox lstApplications.List(i - 1)

If UCase(package.Value("Name")) = UCase(lstApplications.List(i - 1)) Then  'add this
    package.Value("Identity") = "-------"
    package.Value("Password") = "------"


  package.Value("SecurityEnabled") = "Y"  'add this

    packages.SaveChanges  'add this
  end if        'add this
    End If
Next

Commented:
you never compare the package's name with your application name before setting the password and user name

Author

Commented:
thank very much, it worked perfect

Explore More ContentExplore courses, solutions, and other research materials related to this topic.