?
Solved

Add COM+ roles using VB Code

Posted on 2004-07-30
1
Medium Priority
?
346 Views
Last Modified: 2010-05-02
Hi Experts,

I wanted to know how to add existing roles to a component that i add. I have got 3 roles and i want to add these to the components.
I have done most of the code to add a role but could not get the role checked in the security tab od the COM+.

In simple, How do i add a role to a component using vb code.
any sample would be of great help.

working sample contains 100 pts extra.

Thanks in Advance for all the Experts,
Bhalpa
0
Comment
Question by:bhalpa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 26

Accepted Solution

by:
EDDYKT earned 1000 total points
ID: 11678130
Try this

Dim catalog As New COMAdminCatalog
    Dim packages As COMAdminCatalogCollection
    Dim package As COMAdminCatalogObject
    Dim components As COMAdminCatalogCollection
    Dim component As COMAdminCatalogObject
    Dim roles As COMAdminCatalogCollection
    Dim role As COMAdminCatalogObject
    Dim users As COMAdminCatalogCollection
    Dim user As COMAdminCatalogObject
    Dim roleUtil As COMAdminCatalogCollection 'RoleAssociationUtil
    Dim computer As COMAdminCatalogCollection
   
    On Error Resume Next
    Set packages = catalog.GetCollection("Applications")
    packages.Populate
   
    ' Locate desired package
    For Each package In packages
        If package.Value("Name") = "YourPackageName" Then
            Exit For
        End If
    Next
   
    If package Is Nothing Then Exit Sub
   
    ' Iterate through the components and add 'Everyone' to each role
    Set components = packages.GetCollection("Components", package.Key)
    components.Populate
    For Each component In components
        Set roles = components.GetCollection("RolesForComponent", component.Key)
        roles.Populate
        If roles.Count = 0 Then
            Set role = roles.Add
            role.Value("Name") = "Everyone"   ' replace your role name here
            roles.SaveChanges
        End If
    Next
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month14 days, 14 hours left to enroll

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question