Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Add COM+ roles using VB Code

Posted on 2004-07-30
1
Medium Priority
?
352 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 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…

927 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