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:
The line that causes the fail is the last but one, "Set oUser = GetObject(rs.Fields(0).Value)"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 "on error goto missing_name" seems to be ignored, the Error_Handler code is run instead, which produces the text box message shown:
Any clue as to why this won't run as a compiled exe file would be much appreciated.
And Merry Christmas!




Reply With Quote
