Results 1 to 4 of 4

Thread: OLE Error when running from compiled exe

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2015
    Location
    Cambridgeshire, UK
    Posts
    49

    Question OLE Error when running from compiled exe

    I have an application that searches for AD accounts that have passwords soon to expire.

    The code works just fine when I run it from within the IDE editor, but fails when I try it from the compiled .exe file.

    Here's the relevant code snippet:

    Code:
        On Error GoTo Error_Handler
        Text1 = "Scanning AD Users"
        MousePointer = vbHourglass
        Set objRootDSE = GetObject("LDAP://rootDSE")
        DomainContainer = objRootDSE.Get("defaultNamingContext")
        Set conn = CreateObject("ADODB.Connection")
        conn.Provider = "ADSDSOObject"
        conn.open "ADs Provider"
        ldapStr = "<LDAP://" & DomainContainer & ">;(& (objectCategory=person)(objectClass=user));adspath;subtree"
        Set rs = conn.Execute(ldapStr)
        Set objADSystemInfo = CreateObject("ADSystemInfo")
        Set objDomain = GetObject("LDAP://" & objADSystemInfo.DomainDNSName)
        Set objMaxPwdAge = objDomain.Get("maxPwdAge")
        intMaxPwdDays = Abs((objMaxPwdAge.HighPart * 2 ^ 32 + objMaxPwdAge.LowPart) / NANOSECONDS_IN_A_DAY)
        current_row = 2
        On Error GoTo missing_name
        While Not rs.EOF
            Set oUser = GetObject(rs.Fields(0).Value)
            Set objDate = oUser.pwdLastSet
    The line that causes the fail is the last but one, "Set oUser = GetObject(rs.Fields(0).Value)"
    The "on error goto missing_name" seems to be ignored, the Error_Handler code is run instead, which produces the text box message shown:
    Name:  New Bitmap Image.bmp
Views: 285
Size:  146.3 KB

    Any clue as to why this won't run as a compiled exe file would be much appreciated.

    And Merry Christmas!

  2. #2
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: OLE Error when running from compiled exe

    Have you tried running the compiled program with elevated privileges yet?

  3. #3

    Thread Starter
    Member
    Join Date
    Sep 2015
    Location
    Cambridgeshire, UK
    Posts
    49

    Re: OLE Error when running from compiled exe

    WOW!
    Many thanks, Dilettante, it was just as simple as that!

  4. #4
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: OLE Error when running from compiled exe

    Yeah, it is similar to the error you get using WMI on a system where access to it has been locked down through Group Policy or a DACL.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width