Solved

COM+ Security Problem

Posted on 2002-04-29
3
402 Views
Last Modified: 2013-11-25
Hello,

I am having a problem figuring out if a user is in a role in a VB COM+ application.  I have included a reference to "COM+ Services Type Library" (COMSVCS.DLL) and am using the following code:

Function IsAdmin() As Variant
    IsAdmin = COMSVCSLib.GetObjectContext.IsCallerInRole("Admins")
End Function

The problem is that this function always returns true regardless of whether the caller is in the role or not.  Incidentally the GetOriginalCallerName function of the ObjectContext.Security object *is* working.

    Thanks,
    - Lee
0
Comment
Question by:Lear
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
rkot2000 earned 100 total points
ID: 6980504
did you enable/set security for your com+ package.

p.s
 
you need to use like this:

Function IsAdmin() As Boolean
   If GetObjectContext.IsSecurityEnabled = False Then
      'or raise an error
      IsAdmin = False
     
      Exit Function
   End If
   IsAdmin = GetObjectContext.IsCallerInRole("Admins")
End Function
0
 
LVL 5

Expert Comment

by:rkot2000
ID: 6980541
also you may need to make this dll and  create mts/com+ package.

from mts help


Return Values

True
Either the caller is in the specified role, or security is not enabled.
False
The caller is not in the specified role.

Remarks

You use this method to determine whether the direct caller of the currently executing method is associated with a specific role. A role is a symbolic name that represents a user or group of users who have specific access permissions to all components in a given package. Developers define roles when they create a component, and roles are mapped to individual users or groups at deployment time.
IsCallerInRole only applies to the direct caller of the currently executing method. (The direct caller is the process calling into the current server process. It can be either a base client process or a server process.) IsCallerInRole doesn't apply to the process that initiated the call sequence from which the current method was called, or to any other callers in that sequence.

Because IsCallerInRole returns True when the object that invokes it is executing in a client's process, it's a good idea to call IsSecurityEnabled before calling IsCallerInRole. If security isn't enabled, IsCallerInRole won't return an accurate result.
0
 

Expert Comment

by:mirghani
ID: 8172612
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and 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…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

911 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

22 Experts available now in Live!

Get 1:1 Help Now