Solved

COM+ Security Problem

Posted on 2002-04-29
3
399 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

705 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

16 Experts available now in Live!

Get 1:1 Help Now