Solved

Problem with ActiveX Control

Posted on 2002-07-19
9
141 Views
Last Modified: 2010-05-02
I have created an ActiveX control using VB.This ActiveX Control works fine on my machine, but when i try to register the ActiveX Ocx in any other machine other than my machine, it gives me an permission denied error.But if i have logged in as the administrator of that machine then i dont face any problems.Can any one help me .
0
Comment
Question by:Swarnalakshmi
9 Comments
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 7164465
what is this control is doing?
0
 

Author Comment

by:Swarnalakshmi
ID: 7164485
The Control is basically built over a MSFlexgrid, the columns of the FlexGrid are all database driven,for Ex the number columns the Flexgrid is fetched from the database.
It performs other functionalaties like on click of the column header it sorts the data in the column, you can hide the columns,unhide the columns and functions similiar to this.
0
 
LVL 3

Expert Comment

by:PNJ
ID: 7164494
I suspect that the Administrator is the only user that's set up to be able to write to the Registry. This is a problem faced when user accounts are restricted to prevent the user from playing around with the PC setup. Use Control Panel / User And Passwords to see what group the user is in. Are you using "PolEdit" at all to restrict the account? If so, check in there so see how the PC is restricted.

To do this programmatically, you will have to use the "ImpersonateUser" API to temporarily log on as "Administrator" in order to register the control.
0
 

Author Comment

by:Swarnalakshmi
ID: 7164624
We are not using 'PolEdit' and we are using "Impersonate User" and still it does not work
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 3

Expert Comment

by:PNJ
ID: 7164638
OK - the only other thing I know to try is to check that the user you are "impersonating" has "Act As Part Of Operating System" set in their group. See Control Panel / Admin Tools / Local Security Policy / Local Policies / User Rights Assignment.
0
 

Author Comment

by:Swarnalakshmi
ID: 7164652
Yes the user has "Act As a Part of Operating System" set in his group, and stillthe problem persists.
0
 
LVL 3

Expert Comment

by:PNJ
ID: 7164689
Odd, I've extracted all the bits from the module in my system that does exactly what you are trying. This only works on Windows 2000 - not on W95. I don't know about ME, XP etc.

   Declare Function LogOnUser Lib "ADVAPI32.DLL" Alias "LogonUserA" _
      (ByVal lpszUsername As String, _
      ByVal lpszDomain As String, ByVal lpszPassword As String, _
      ByVal dwLogonType As Long, ByVal dwLogonProvider As Long, _
      phToken As Long) As Long

   Declare Function ImpersonateLoggedOnUser Lib "ADVAPI32.DLL" _
      (ByVal hToken As Long) As Long

   Declare Function RevertToSelf Lib "ADVAPI32.DLL" () As Long

  Dim mlTokenHandle       As Long

  ...begin program...
  ' Log on as a user who can update the registry
  LogOnAdmin
...some code...

  SwitchToAdmin
  ' Copy the DLL to "system32"
  FileCopy DLLPathName, DestDir & DLLName
  RegisterDLL DestDir & DLLName, False
  RevertToSelf ' Log off Admin
  ...done...

Private Sub LogOnAdmin()

   Dim Result As Boolean, Domain As String, User As String, Pass As String

   Const LOGON32_LOGON_INTERACTIVE = 2
   Const LOGON32_PROVIDER_DEFAULT = 0

   ' See if this Windows 2000 function works
   If Not CBool(RevertToSelf()) Then
      MsgBox "RevertToSelf failed. " & vbCrLf
      ' So can't do this functionality.
      Exit Sub
   End If

   User = "Auser"
   Pass = "APass" ' Case Sensitive
   Domain = "ADomain"

   If Not CBool(LogOnUser(User, Domain, Pass, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, mlTokenHandle)) Then

      MsgBox "LogonUser failed: User: " & User & _
         " Domain: " & Domain & vbCrLf
      Exit Sub

   End If

End Sub

Sub SwitchToAdmin()

   If Not CBool(ImpersonateLoggedOnUser(mlTokenHandle)) Then
      MsgBox "ImpersonateLoggedUser failed." & vbCrLf
   End If

End Sub
   
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 8031858
Hi Swarnalakshmi,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Refund points and save as a 0-pt PAQ.

Swarnalakshmi, Please DO NOT accept this comment as an answer.
EXPERTS: Post a comment if you are certain that an expert deserves credit.  Explain why.
==========
DanRollins -- EE database cleanup volunteer
0
 

Accepted Solution

by:
SpideyMod earned 0 total points
ID: 8095531
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
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 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…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

744 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

14 Experts available now in Live!

Get 1:1 Help Now