Re: User property vbscript

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Doh! Nevermind,

objitem.setinfo

....is what I was missing!

Thanks for reading this anyway.


nntp.aioe.org wrote:
P.S. I also tried this technique (everything between the stars):

***********************************
Const ADS_PROPERTY_UPDATE = 2
Set colItems = GetObject _
("LDAP://ou=test,DC=company1,DC=local";)
colItems.Filter = Array("user")
For Each objItem in colItems
objitem.put "displayname", objitem.givenname _
& " " & objitem.sn & " (Company1)"
Next
***********************************

The above script runs without errors, but the problem is it doesn't modify anything.

nntp.aioe.org wrote:
I'm trying to script the display field of all user objects in an OU. The goal of the script is to take the user first name, insert a space, take the user last name, insert a space, and then quote custom text.

For example: The user Firstname is David and his Lastname is Consumer and the text to append is (Company1). His display name should look like this:

David Consumer (Company1)

The script I've pieced together does everything well except when I try to enumerate the "sn" schema property of the user object it states that the object could not be found in the schema cache.

Here is the code so far (everything between the stars):

*******************************
Const ADS_PROPERTY_UPDATE = 2
Set OU = GetObject _
("LDAP://OU=test,DC=company1,DC=local";)
For Each objUser In OU
If objUser.Class = "user" Then
objUser.Put "displayname", objUser.Get("givenname") _
& " " & objUser.Get("sn") & " " & "(Company1)"
objUser.SetInfo
End If
Next
*******************************


The ldap bind is successful, the retrieval of the givenname property is successful, but when it comes to the surname ("sn") property it states that it doesn't exist. I fire up adsiedit.msc to confirm that the field exists and sure enough it does.

Anyone want to take a stab at what I might be doing wrong?

(Just a side note, If I rewrite the script and target a specific user and wscript.echo the "sn" property it returns it just fine).
.



Relevant Pages

  • Re: User property vbscript
    ... Const ADS_PROPERTY_UPDATE = 2 ... Set colItems = GetObject _ ... The above script runs without errors, but the problem is it doesn't modify anything. ...
    (microsoft.public.windows.server.active_directory)
  • Re: script to get all the groups from AD
    ... > I am running this script: ... > Set colItems = GetObject _ ... > For Each objItem in colItems ...
    (microsoft.public.scripting.vbscript)
  • GetObject Error Checking
    ... in my script I am passing the server name to the script to see what the OS ... machine does not exist or is unavailable 'GetObject'. ... Set colItems = objWMIService.ExecQuery("Select Caption from ...
    (microsoft.public.windows.server.scripting)
  • Re: 2001 - rule
    ... I will have to try and find a copy of entourage 2001 lying around to ... (script compiler had me add an extra "then" in the last clause, ... repeat with aRecipient in theRecipients ... displayName as text) ...
    (microsoft.public.mac.office.entourage)
  • Re: Error handling bug on GetObject?
    ... I seem to have hit a bug in the error handling of VBScript. ... If Error Handling is not turned on, then the script crashes on the GetObject ... In a main routine, this code behaves exactly as expected. ...
    (microsoft.public.scripting.vbscript)