?
Solved

COM+ Security Problem

Posted on 2002-04-29
3
Medium Priority
?
429 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
[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
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
rkot2000 earned 400 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

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

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…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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 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…

752 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