Question : How to copy a custom attribute from 1 field to another

i need to find a script to move the value from a custom attribute to another field with AD. The value currently is under customattribute1 and i need to move that to Title under the organization tab. this is needed for over 2000 users.... so a script or a script on an OU. ideas?

Answer : How to copy a custom attribute from 1 field to another


Ah sorry, it helps if I tell it to pull that value in the search. Added it below, should be a little more successful now.

Chris
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
Dim objConnection : Set objConnection = CreateObject("ADODB.Connection")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
 
Dim objCommand : Set objCommand = Createobject("ADODB.Command")
objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 1000
 
' *** Please correct the path below ***
objCommand.CommandText = ";" & _
  "(&(objectClass=user)(objectCategory=person)(extensionAttribute1=*));" & _
  "name,title,distinguishedName,extensionAttribute1;subtree"
 
Dim objRecordSet : Set objRecordSet = objCommand.Execute
 
Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objFile : Set objFile = objFSO.OpenTextFile("BackupFile.csv", 2, True, 0)
 
Do Until objRecordSet.EOF
  Dim strExtAttr1 : strExtAttr1 = objRecordSet.Fields("extensionAttribute1").Value
  Dim strTitle
  If Not IsNull(objRecordSet.Fields("title")) Then
    strTitle = objRecordSet.Fields("title").Value
  Else
    strTitle = ""
  End If
 
  objFile.WriteLine objRecordSet.Fields("distinguishedName").Value & vbTab & _
    objRecordSet.Fields("name").Value & vbTab & strTitle & vbTab & strExtAttr1
 
  Dim objUser : Set objUser = GetObject("LDAP://" & objRecordSet.Fields("distinguishedName").Value)
  ' Add the value to title
  objUser.Put "title", strExtAttr1
  ' This clears the value from extensionAttribute1
  objUser.PutEx 1, "extensionAttribute1", 0
  objUser.SetInfo
 
  objRecordSet.MoveNext
Loop
Open in New Window Select All
Random Solutions  
 
programming4us programming4us