Solved

Problem with ActiveX Control

Posted on 2002-07-19
9
142 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

932 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

8 Experts available now in Live!

Get 1:1 Help Now