I would like to create a script which is meant to run only once and update all the 'mail' fields (for the user email address). I have the bit prepared for how to generate the email address from the user's name, and I got as far as this:
My issue is that the recordset is, well, just a recordset - I can't figure out how to get information from this query which is relevant enough to connect to that particular user object and make the modification.
Am I thinking about this totally incorrectly, or just missing some critical bit of knowledge?
Thanks!
Tao Te Ching Discussions : Chapter 9 (includes links to previous chapters)
What is the nature of conflict?
Code:
On Error Resume Next
Const ADS_SCOPE_SUBTREE = 2
Set objRootDSE = GetObject ("LDAP://RootDSE")
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 Name, givenName, sn, mail, ou, cn FROM 'LDAP://dc=[removed],dc=[removed]' WHERE objectCategory='user'"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
'Wscript.Echo objRecordSet.Fields("Name").Value
Set email = '' This tidbit removed for security ''
Set objUser = GetObject("LDAP://cn=" & objRecordSet.Fields("Name").value & "," & _
objRootDSE.Get("DefaultNamingContext"))
objUser.Put "mail", email
objUser.SetInfo
'wscript.echo objrecordset.fields("mail").value
objRecordSet.MoveNext
Loop
My issue is that the recordset is, well, just a recordset - I can't figure out how to get information from this query which is relevant enough to connect to that particular user object and make the modification.
Am I thinking about this totally incorrectly, or just missing some critical bit of knowledge?
Thanks!
Tao Te Ching Discussions : Chapter 9 (includes links to previous chapters)
What is the nature of conflict?