Re: finding out user



It looks like when I pasted the code into the post, many carriage returns
were added. Your error message will indicate the line number in the script
where the error was raised. It sounds like one of my statements that uses a
line continuation character, the "_", to continue the statement on the next
line got a carriage return inserted. The next line is a blank instead of the
rest of the line.

I would try removing any blank lines after any statements that end with "_".

Also, often word wrapping messes up lines that are pasted in a message. It's
possible that one of the lines was broken up into 2 lines. If so, you will
need to remove the extra carriage return, making the statement one line
again. In fact, that's why I use the line continuation characters, to avoid
this.

If you aren't used to this it can be tricky, but the error message should
indicate the line with the problem.

--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--

"Abhi" <Abhi@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:8D668E7A-0B5E-4247-AF19-A334710F5BFB@xxxxxxxxxxxxxxxx
Hi Richard,
I tried it but it gave me the following error upon executing

Microsoft VBScript compilation error: Expected statement.



"Richard Mueller [MVP]" wrote:

Abhi wrote:

How can I find out users based on the user account creation date? I
have
tried a sample script which is givne in Technet, but it is failing.Any
pointers are highly appreciated

You can use ADO in a VBScript program to retrieve attributes of objects
that
meet conditions. In this case, the whenCreated attribute can be used to
filter user objects. See this link for information on using ADO:

http://www.rlmueller.net/ADOSearchTips.htm

The whenCreated attribute is generalized time in the form
yyyymmddhhnnss.0Z
(where nn is minutes). For example, to retrieve the NT names (pre-Windows
2000 logon name) and Distinguished Names of all users created during the
day
June 20, 2007:
==========
Dim adoCommand, adoConnection, strBase, strFilter, strAttributes

Dim objRootDSE, strDNSDomain, strQuery, adoRecordset, strName, strDN



' Setup ADO objects.

Set adoCommand = CreateObject("ADODB.Command")
Set adoConnection = CreateObject("ADODB.Connection")
adoConnection.Provider = "ADsDSOObject"
adoConnection.Open "Active Directory Provider"
adoCommand.ActiveConnection = adoConnection



' Search entire Active Directory domain.

Set objRootDSE = GetObject("LDAP://RootDSE";)

strDNSDomain = objRootDSE.Get("defaultNamingContext")
strBase = "<LDAP://"; & strDNSDomain & ">"


' Filter on user objects created after midnight 6/20/2007 and

' before midnight 6/21/2007.
strFilter = "(&(objectCategory=person)(objectClass=user)" _

& "(whenCreated>=20070620000000.0Z)(whenCreated<=20070621000000.0Z))"



' Comma delimited list of attribute values to retrieve.
strAttributes = "sAMAccountName,distinguishedName"



' Construct the LDAP syntax query.
strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
adoCommand.CommandText = strQuery
adoCommand.Properties("Page Size") = 100
adoCommand.Properties("Timeout") = 30
adoCommand.Properties("Cache Results") = False



' Run the query.
Set adoRecordset = adoCommand.Execute


' Enumerate the resulting recordset.
Do Until adoRecordset.EOF

' Retrieve values and display.
strName = adoRecordset.Fields("sAMAccountName").Value

strDN = adoRecordset.Fields("distinguishedName").value

Wscript.Echo "NT Name: " & strName & ", DN: " & strDN

' Move to the next record in the recordset.
adoRecordset.MoveNext
Loop



' Clean up.

adoRecordset.Close

adoConnection.Close


--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--





.



Relevant Pages

  • Re: Form Security
    ... After all this, if no error message has been generated, the form contents are emailed to me. ... I'm no Linux guru, so I don't know what someone could do to cause problems with this script, other than spam me. ... What he's proposing is false security - which is worse than no security ...
    (comp.lang.php)
  • RE: Cannot Edit Logion Scripts
    ... remove the script that you would like to edit. ... Please capture a screenshot of the error message received on the client ... Microsoft Online Newsgroup Support ... This newsgroup only focuses on SBS technical issues. ...
    (microsoft.public.windows.server.sbs)
  • Re: Move computers account to another OU from a txt list
    ... I need a script, that list from OU or txt file, that contains machine ... user objects by changing the ADO filter in the loop. ... ' Change the base of the query to a specific OU. ... ' Filter on all user objects. ...
    (microsoft.public.windows.server.scripting)
  • Re: Error in script of Internet Explorer
    ... Uncheck the box to Display a notification about every script error. ... Windows Script 5.6 for Windows 2000 and XP ... Error Message When You Browse the Web: An Error Has Occurred in the Script ... Please reply to the newsgroup so others may benefit. ...
    (microsoft.public.windows.inetexplorer.ie6.browser)
  • Re: Sound file
    ... There shouldn't be any problems in the limited user accounts. ... The only other problem just about has to be with the attaching of the .wav ... > Common script errors messages can be eliminated by Clicking: ... >> click on the html file we get an error message and the wav file does ...
    (microsoft.public.windowsxp.accessibility)