Solved

Add COM+ roles using VB Code

Posted on 2004-07-30
1
336 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
1 Comment
 
LVL 26

Accepted Solution

by:
EDDYKT earned 250 total points
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

744 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now