[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

COM+ Security Problem

Posted on 2002-04-29
3
Medium Priority
?
439 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Suggested Courses

650 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