WILDPACKET
Mon Mar 10 20:43:09 CDT 2008
I will check this out.
Thanks,
"Richard Mueller [MVP]" wrote:
> The most likely cause of the error on the SetInfo statement is that your
> query retrieves both user and contact objects. Contact objects do not have a
> scriptPath attribute. This can be avoided by using:
>
> objCommand.CommandText = _
> "SELECT ADsPath " _
> & "FROM 'LDAP://cn=users,dc=lab,dc=local' " _
> & "WHERE objectCategory='person' AND objectClass='user' AND NOT
> scriptPath='*'"
>
> --
> Richard Mueller
> Microsoft MVP Scripting and ADSI
> Hilltop Lab -
http://www.rlmueller.net
> --
>
> "WILDPACKET" <WILDPACKET@discussions.microsoft.com> wrote in message
> news:352EA347-E70B-4000-94C8-FB59406D7991@microsoft.com...
> >
> > Hi Richard:
> >
> > It works now after I added the following line at the very top of the
> > script
> > ....
> >
> > On Error Resume next
> >
> > and all is Kosher!
> >
> > Thank you for your support.
> >
> >
> >
> > "Richard Mueller [MVP]" wrote:
> >
> >> Line 24 in my copy of the script is a blank line near the end (after the
> >> loop, before the clean up). The script runs for me without error. I
> >> pasted
> >> it exactly from my post in the newsgroup, except I changed the base of
> >> the
> >> search (line 14) to reflect my domain. I only have a few users in the
> >> cn=Users container, but all now show logon.bat on the profile tab in
> >> ADUC,
> >> unless they already had a logon script specified. Which line is line 24
> >> in
> >> your copy?
> >>
> >> --
> >> Richard Mueller
> >> Microsoft MVP Scripting and ADSI
> >> Hilltop Lab -
http://www.rlmueller.net
> >> --
> >>
> >> "WILDPACKET" <WILDPACKET@discussions.microsoft.com> wrote in message
> >> news:9CCBF0AD-29AC-4835-ADFC-DE179729E840@microsoft.com...
> >> >
> >> > Richard thanks for your response.
> >> >
> >> > I ran the scriot as is and gives error on Line 24 and says character 5.
> >> >
> >> > Advise Plz.
> >> >
> >> >
> >> >
> >> >
> >> >
> >> > "Richard Mueller [MVP]" wrote:
> >> >
> >> >> WILDPACKET wrote:
> >> >>
> >> >> > trying to add logon.bat to under the AD users properties ....under
> >> >> > Logon
> >> >> > Script field.
> >> >> >
> >> >> > I ahve this Vb ...and I am not a VB guy ...can somebody please
> >> >> > adddress
> >> >> > for
> >> >> > me ...
> >> >> > I want the Logon.bat added Logon Script field to all my users in AD
> >> >> > and
> >> >> > the
> >> >> > ones which already have it shoudl be ignored.
> >> >> >
> >> >> >
> >> >> >
> >> >> > On Error Resume Next
> >> >> >
> >> >> > Const ADS_SCOPE_SUBTREE = 2
> >> >> >
> >> >> > Set objConnection = CreateObject("ADODB.Connection")
> >> >> > Set objCommand = CreateObject("ADODB.Command")
> >> >> > objConnection.Provider = "ADsDSOObject"
> >> >> > objConnection.Open "Active Directory Provider"
> >> >> > Set objCommand.ActiveConnection = objConnection
> >> >> >
> >> >> > objCommand.Properties("Page Size") = 1000
> >> >> > objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
> >> >> >
> >> >> > objCommand.CommandText = _
> >> >> > "SELECT ADsPath FROM 'LDAP://cn=users,dc=lab,dc=local' WHERE
> >> >> > objectCategory='user' "
> >> >> > Set objRecordSet = objCommand.Execute
> >> >> > Const ADS_PROPERTY_APPEND = 3
> >> >> >
> >> >> > objUser.PutEx ADS_PROPERTY_APPEND, _
> >> >> > objUser.scriptPath, ("logon.bat")
> >> >> > objUser.SetInfo
> >> >> >
> >> >> >
> >> >> > Advise Please. Thanks
> >> >> >
> >> >>
> >> >> I suggest the code below. I added a clause to the query to retrieve
> >> >> users
> >> >> only if there is no value assigned to the scriptPath attribute. Note
> >> >> you
> >> >> must enumerate the resulting recordset in a loop, then bind to each
> >> >> user
> >> >> object (using the value of ADsPath retrieved), assign the value to the
> >> >> scriptPath attribute, then invoke the SetInfo method to save changes.
> >> >> ==========
> >> >> Const ADS_SCOPE_SUBTREE = 2
> >> >>
> >> >> Set objConnection = CreateObject("ADODB.Connection")
> >> >> Set objCommand = CreateObject("ADODB.Command")
> >> >> objConnection.Provider = "ADsDSOObject"
> >> >> objConnection.Open "Active Directory Provider"
> >> >> Set objCommand.ActiveConnection = objConnection
> >> >>
> >> >> objCommand.Properties("Page Size") = 1000
> >> >> objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
> >> >>
> >> >> objCommand.CommandText = _
> >> >> "SELECT ADsPath " _
> >> >> & "FROM 'LDAP://cn=users,dc=lab,dc=local' " _
> >> >> & "WHERE objectCategory='user' AND NOT scriptPath='*'"
> >> >> Set objRecordSet = objCommand.Execute
> >> >>
> >> >> Do Until objRecordSet.EOF
> >> >> Set objUser = GetObject(objRecordset.Fields("ADsPath").Value)
> >> >> objUser.scriptPath = "logon.bat"
> >> >> objUser.SetInfo
> >> >> objRecordset.MoveNext
> >> >> Loop
> >> >>
> >> >> ' Clean up.
> >> >> objRecordset.Close
> >> >> objConnection.Close
> >> >>
> >> >> --
> >> >> Richard Mueller
> >> >> Microsoft MVP Scripting and ADSI
> >> >> Hilltop Lab -
http://www.rlmueller.net
> >> >> --
> >> >>
> >> >>
> >> >>
> >>
> >>
> >>
>
>
>