1 Attachment(s)
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:
Attachment 164355
Any clue as to why this won't run as a compiled exe file would be much appreciated.
And Merry Christmas!
Re: OLE Error when running from compiled exe
Have you tried running the compiled program with elevated privileges yet?
Re: OLE Error when running from compiled exe
WOW!
Many thanks, Dilettante, it was just as simple as that!:)
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.