Solved

COM+ Security Problem

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
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…

777 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