Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Any help would be greatly appreciated.
AddExtender("wwads34i.dll") AddExtender("wwsop34i.DLL") title = "Check User Logons - v1.00" boxtitle(title) today = TimeYmdHms() days90 = TimeSubtract(today, "0000:00:90:00:00:00") data = "" sStarPath = "LDAP://corpdc03.corp.ent.MYDOMAIN.org/DC=corp,DC=ent,DC=MYDOMAIN,DC=org" sFilter = `(&(objectCategory=Person)(lastlogon<=%days90%))` ;search for lastlogon property greated than 90 days old astatusbar(0,title,"Generating AD User List...",0,0) MyOuPaths = dsFindPath(sStarPath, sFilter) y = 0 oucount = itemcount(myoupaths,@tab) for x = 1 to oucount astatusbar(1,title,"Checking User Logons... 90 Day Old",oucount,x) ou = itemextract(x,myoupaths,@tab) cn = dsGetProperty(ou, "cn") ll = dsGetProperty(ou, "lastlogon") if ll != 0 then ll = timediffdays(today,ll) lastname = dsGetProperty(ou, "sn") firstname = dsGetProperty(ou, "givenname") parentou = dsGetProperty(dsGetPrntPath(ou), "CN") createdate = timediffdays(today,dsGetProperty(ou, "createTimeStamp")) data = strcat(data,cn,",",lastname,",",firstname,",",parentou,",",ll,@crlf) next sFilter = "(&(objectCategory=Person)(!lastlogon=*))" ;search for empty lastlogon property astatusbar(0,title,"Generating AD User List...",0,0) MyOuPaths = dsFindPath(sStarPath, sFilter) y = 0 oucount = itemcount(myoupaths,@tab) for x = 1 to oucount astatusbar(1,title,"Checking User Logons... Empty Values",oucount,x) ou = itemextract(x,myoupaths,@tab) cn = dsGetProperty(ou, "cn") lastname = dsGetProperty(ou, "sn") firstname = dsGetProperty(ou, "givenname") parentou = dsGetProperty(dsGetPrntPath(ou), "CN") createdate = timediffdays(today,dsGetProperty(ou, "createTimeStamp")) data = strcat(data,cn,",",lastname,",",firstname,",",parentou,",0",@crlf) next astatusbar(2,title,"",0,0) logfile = fileopen("c:\Log.txt","write") filewrite(logfile,data) fileclose(logfile) message("","Done!")
If the error occurs on the dsFindPath. The most likely cause is the server is temporarily unavailable. Note: You can easily force this error by simply passing a BAD server name:
AddExtender("WWADS44I.DLL") dcName ="DummyName" samName = "Whatever" sFilter ="(&(objectCategory=Person)(sAMAccountName=%samName%))" dcPath = StrCat("LDAP://%dcName%/","DC=App,DC=Ad,DC=domain,DC=net") ouPath = dsFindPath(dcPath,sFilter)I would recommend adding code to your script that captures all 1073 errors and logs them out to a file along with details about the servername and the time the error occured. It might help you track down the problem on your network.
You could try re-writing the script using WB's OLE/COM implementation. The extender tends to fetch data from the server "on the wire", whereas using OLE (like VB script does) will pull all the properties of an object into a local cache and fetch individual values without re-contacting the server. If your server is heavily tasked this may fix your problem. This could also potentially fix the problem, if it is being caused by an extender bug.
The problem is that the extender is prone to timing issue because of all the extra network traffic it generates.
There are several points to keep in mind here.
Here is some revised code that uses COM instead of dsGetProperty to grab those user properties.
AddExtender("wwads34i.dll") AddExtender("wwsop34i.DLL") title = "Check User Logons - v1.00" BoxTitle(title) today = TimeYMDHMS() days90 = TimeSubtract(today, "0000:00:90:00:00:00") data = "" sadsipath="LDAP://rootDSE" svalue=dsGetProperty (sadsipath,"defaultNamingContext") sstarpath=StrCat("LDAP://",svalue) sfilter = `(&(objectCategory=Person)(lastlogon<=%days90%))` ; Search for lastlogon property greated than 90 days old. aStatusBar(0,title,"Generating AD User List...",0,0) myoupaths = dsFindPath(sstarpath, sfilter) oucount = ItemCount(myoupaths,@Tab) For x = 1 To oucount aStatusBar(1,title,"Checking User Logons... 90 Day Old",oucount,x) ou = ItemExtract(x,myoupaths,@Tab) objuser = ObjectOpen(ou) cn = objuser.cn ll = objuser.lastlogon If ll != 0 Then ll = TimeDiffDays(today,ll) lastname = objuser.sn firstname = objuser.givenname parentou = objuser.parent createdate = TimeDiffDays(today,objuser.createtimestamp) data = StrCat(data,cn,",",lastname,",",firstname,",",parentou,",",ll,",",createdate,@CrLf) ObjectClose(objuser) Next sfilter = "(&(objectCategory=Person)(!lastlogon=*))" ; Search for empty lastlogon property. aStatusBar(0,title,"Generating AD User List...",0,0) myoupaths = dsFindPath(sstarpath, sfilter) oucount = ItemCount(myoupaths,@Tab) For x = 1 To oucount aStatusBar(1,title,"Checking User Logons... Empty Values",oucount,x) ou = ItemExtract(x,myoupaths,@Tab) objuser = ObjectOpen(ou) cn = objuser.cn lastname = objuser.sn firstname = objuser.givenname parentou = objuser.parent createdate = TimeDiffDays(today,objuser.createtimestamp data = StrCat(data,cn,",",lastname,",",firstname,",",parentou,",",createdate,@CrLf) ObjectClose(objuser) Next aStatusBar(2,title,"",0,0) logfile = FileOpen("c:\Log.txt","write") FileWrite(logfile,data) FileClose(logfile)
Article ID: W15797
File Created: 2010:10:07:12:54:10
Last Updated: 2010:10:07:12:54:10