Re: Update Notes Field
- From: "Debra Brown" <debrabrown@xxxxxxxx>
- Date: Thu, 23 Oct 2008 09:49:18 -0700
Thanks very much for correcting my error. I put the statement on the same line and it works. I was able to run the script without any problems.
Thanks for the second script and the instruction. It works, too. May I ask you two questions? I am using the second script to create a new user. I am stumped on this one. Is there a way to add the user in a group? For example, I want to add the user to "OU=Marketing,OU=Various Sites,DC=local,DC=company,DC=com"
My other question which is not important. If it is too time consuming, please ignore it. I want to use your second script to add multiple users (including notes and groups) instead of one user. Is there a way to accomplish this?
Thanks.
"Richard Mueller [MVP]" <rlmueller-nospam@xxxxxxxxxxxxxxxxxxxx> wrote in message news:%23qVAhtLNJHA.4600@xxxxxxxxxxxxxxxxxxxxxxx
I believe word wrapping messed up your copy of the script. I do not get that error. The following statement needs to be on one line:
Set objUser = GetObject("LDAP://CN=Shoe_Albert,OU=Marketing,OU=Site Users,DC=local,DC=company,DC=com")
The info attribute can be assigned a value when the user object is created, but I don't see where dsadd can do it.
I don't use the command line utilities, like dsadd, because the syntax is too difficult to remember. I'm not sure any can easily handle values with non-display characters like carriage returns. I use VBScript programs. For example to create a user and assign a few attributes (I use lots of comments):
========
' Constant for multi-valued attributes.
Const ADS_PROPERTY_APPEND = 3
' Bind to parent container/OU.
' This is where the user object will reside.
' This statement must be on one line.
Set objOU = GetObject("LDAP://ou=Marketing,ou=Site users,dc=Local,dc=company,dc=com")
' Specify Common Name (required).
' Must be unique in the container/OU.
strCN = "Shoe_Albert"
' Create the user object.
Set objUser = objOU.Create("user", "cn=" & strCN)
' Assign pre-Windows 2000 logon name (required).
' Must be unique in the domain.
objUser.sAMAccountName = "SAlbert"
' Save new object.
objUser.SetInfo
' Set password (object must be saved).
objUser.SetPassword "xzY$321q"
' Expire the password, so it must be changed at next logon.
objUser.pwdLastSet = 0
' Enable the user account.
objUser.AccountDisabled = False
' Assign first name.
objUser.givenName = "Shoe"
' Assign last name.
objUser.sn = "Albert"
' Assign telephone number.
objUser.telephoneNumber = "213-333-5432"
' Assign other telephone numbers (2 in this case).
' This statement must be one line.
objUser.PutEx ADS_PROPERTY_APPEND, "otherHomePhone", Array("213-333-5433", "213-333-5434")
' Assign home phone.
objUser.homePhone = "213-333-1234"
' Assign mobile phone.
objUser.mobile = "213-333-8765"
' Assign "Notes" on "Telephones" tab of ADUC.
objUser.info = "Contact John Smith" _
& vbCrLf & "ABC Company" _
& vbCrLf & "Telephone number: xxx-xxx-xxxx" _
& vbCrLf & "Email address: Smith_John@xxxxxxx"
' Save changes.
objUser.SetInfo
=========
For the names of attributes of user objects, check the first spread*** linked on this page:
http://www.rlmueller.net/UserAttributes.htm
The only mandatory user attributes are cn (specified with the Create method) and sAMAccountName. All multi-valued attributes (like otherHomePhone) require the PutEx method. Most attributes are string values, and VBScript strings can include the character vbCrLf (carriage return line feed). Strings are concatenated with the & symbol. Any statement can be continued on the next line using the "_" line continuation character. Comments start with a single quote character.
--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--
"Debra Brown" <debrabrown@xxxxxxxx> wrote in message news:eeb0uUJNJHA.4716@xxxxxxxxxxxxxxxxxxxxxxxThanks very much for your prompt response and information. I saved your script as notes.vbs. I ran the script file at the server from the Command Prompt "CSript notes.vbs". I got the error message "notes.vbs (1,62) Microsoft VBScript compilation error: terminated string constant. That is OK. I will try your first suggestion.
May I ask you another question? Is there a way to add Notes information at the same time I add the new users? I tried DSADD command and it did not have the Notes attribute. Thanks.
"Richard Mueller [MVP]" <rlmueller-nospam@xxxxxxxxxxxxxxxxxxxx> wrote in message news:OVxFjjINJHA.2348@xxxxxxxxxxxxxxxxxxxxxxx
"Richard Mueller [MVP]" <rlmueller-nospam@xxxxxxxxxxxxxxxxxxxx> wrote in message news:OSjedcINJHA.4440@xxxxxxxxxxxxxxxxxxxxxxxDebra Brown wrote:
We are running Active Directory 2003 on Windows 2003 server. How do you update the Notes field in Active Directory for Users and Computers by using LDIFDE? The Note field is blank and I want to add the information to it. The information would look like this:
Contact John Smith
ABC Company
Telephone number: xxx-xxx-xxxx
Email address: Smith_John@xxxxxxx
I had this syntax and it gave me this error message: There is a syntax error in the input file Filed on line 4. The last token starts with 'C'.
dn: CN=Shoe_Albert,OU=Marketing,OU=Site Users,DC=local,DC=company,DC=com
changetype: modify
replace: info
info: Contact John Smith
ABC Company
Telephone number: xxx-xxx-xxxx
Email address: Smith_John@xxxxxxx
If there is another way to add the information to the Notes field, please let me know.
Thanks.
The "info" attribute is a single-value string attribute. If you assign a value similar to yours, with carriage returns between the lines, and then export with ldifde, you will see that the ldf file has the value in Base64 encoding (as if it is a binary value). For example:
Line1
Line2
Line3
results in:
info:: TGluZTENCkxpbmUyDQpMaW5lMw==
Base64 encoding is defined in IETF RFC 2045, Section 6.8. Not pretty. The only thing I can suggest if you are assigning the same value to many users, modify one user manually in ADUC, export to an ldf file, and copy the Base64 encoded string into your input file. Or, assign one long string (in one line) and let it word wrap in the ADUC Notes field. Apparently any non-display characters require that the entire value be Base64 encoded.
--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--
Another option is a VBScript program. For example (watch for line wrapping):
========
' Bind to the user object.
Set objUser = GetObject("LDAP://CN=Shoe_Albert,OU=Marketing,OU=Site Users,DC=local,DC=company,DC=com")
' New Notes value, as one string with embedded carriage returns (vbCrLf characters).
strInfo = "Contact John Smith" _
& vbCrLf & "ABC Company" _
& vbCrLf & "Telephone number: xxx-xxx-xxxx" _
& vbCrLf & "Email address: Smith_John@xxxxxxx"
' Assign new value to info attribute.
objUser.info = strInfo
' Save changes.
objUser.SetInfo
--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--
.
- Follow-Ups:
- Re: Update Notes Field
- From: Richard Mueller [MVP]
- Re: Update Notes Field
- References:
- Update Notes Field
- From: Debra Brown
- Re: Update Notes Field
- From: Richard Mueller [MVP]
- Re: Update Notes Field
- From: Richard Mueller [MVP]
- Re: Update Notes Field
- From: Debra Brown
- Re: Update Notes Field
- From: Richard Mueller [MVP]
- Update Notes Field
- Prev by Date: RE: Privileges
- Next by Date: Re: Adding a Windows 2003 R2 server to a Windows 2000 Domain
- Previous by thread: Re: Update Notes Field
- Next by thread: Re: Update Notes Field
- Index(es):