Hello
Bit confused here and it's all about Functions.
This script worked well until I added a request to get the authOrig field. This is an array that needed to be called. I got over this hurdle by adding the " If Not IsNull" string and it does work. However it does not pass this onto the Logfile. Ahha says I, a function will pass a value to the main script. And that's where I am after a few hours.
Would somebody mind looking at this please and saying something like ... "You numpty, this is what you do ......"
Cheers
' --------------------------
----------
----------
----------
----------
----------
----------
----------
---------
const ForReading = 1
const ForWriting = 2
const ForAppending = 8
Const ADS_SCOPE_SUBTREE = 2
' Useraccountcontrol Enabled or Disabled accounts
' 512 = enabled
' 514 = disabled
' On Error Resume Next
set fso = CreateObject("Scripting.Fi
leSystemOb
ject")
set logfile = fso.OpenTextFile("Logfile.
txt", ForWriting)
dim strarray
Set objConnection = CreateObject("ADODB.Connec
tion")
Set objCommand = CreateObject("ADODB.Comman
d")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnectio
n = objConnection
objCommand.Properties("Pag
e Size") = 1000
objCommand.Properties("Sea
rchscope")
= ADS_SCOPE_SUBTREE
objCommand.CommandText = _
"SELECT cn, distinguishedName, authOrig, otherHomePhone, msExchHideFromAddressLists
, Useraccountcontrol, samaccountname, displayname FROM 'LDAP://DOMAIN' WHERE objectcategory='user'"
Set objRecordSet = objCommand.Execute
value(strarray)
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
' Wscript.Echo objRecordSet.Fields("cn").
Value
' --------------------------
----------
----------
----------
----------
-----
strDN = objRecordSet.Fields("disti
nguishedNa
me").Value
strsam = objRecordSet.Fields("samac
countname"
).Value
strcn = objRecordSet.Fields("cn").
Value
strdisplayname = objRecordSet.Fields("displ
ayname").V
alue
strhide = objRecordSet.Fields("msExc
hHideFromA
ddressList
s").Value
strdisable = objRecordSet.Fields("Usera
ccountcont
rol").Valu
e
' wscript.echo objRecordSet.Fields("cn").
Value
' --------------------------
----------
----------
----------
----------
-----
function value(strarray)
' If the value is in array use this
If Not IsNull(objRecordSet.Fields
("authOrig
").Value) Then
For Each strarray in objRecordSet.Fields("authO
rig").Valu
e
Wscript.Echo (strarray)
Next
End If
' --------------------------
----------
----------
----------
----------
-----
Wscript.Echo (strarray)
objRecordSet.MoveNext
logfile.writeline(strsam & "|" & strcn & "|" & strhide & "|" & strdisplayname & "|" & strdisable & "|" & strarray)
end function
Loop
wscript.echo("Complete")
Start Free Trial