LDAP / SiteServer Migration

This script will migrate LDAP and SiteServer user list to another LDAP SiteServer

CodeFunctionName
What is this?

Public

Not Tested

Original Work
<%
Option Explicit
Call MigrateMembers
Sub MigrateMembers
Dim strSourceLdapPath
Dim strTargetLdapPath
Dim strFontStyle

Dim oLDAP
Dim oADsSourceContainer
Dim oADsTargetContainer
Dim oADsNewUser
Dim oADsOldUser

On Error Resume Next
strFontStyle = " <font face=Tahoma size=1 >"
'**********************************************************
' Enter the LDAP Source Members Path To Copy From...
'**********************************************************
' strTargetLdapPath = "LDAP://SourceLDAPMachine:389/dc=mycompany/dc=com"
strSourceLdapPath = "LDAP://Piett:1003/o=SRC/ou=members"

'**********************************************************
' Enter the LDAP Target Members Path To Copy To...
'**********************************************************
' strTargetLdapPath = "LDAP://TargetLDAPMachine:389/dc=mycompany/dc=com"
strTargetLdapPath = "LDAP://Xfernal:389/o=SRC/ou=members"

Set oLDAP = GetObject("LDAP:")
If Err.Number < > 0 Then
Response.Write strFontStyle & Err.Number & Err.Description
End If

'**********************************************************
' This must be set to the Admin Account on the the LDAP Source
'**********************************************************
Set oADsSourceContainer = oLDAP.OpenDSObject(strSourceLdapPath, _
"cn=Administrator,ou=Members,o=SRC", "secret", 0)
If Err.Number < > 0 Then
Response.Write strFontStyle & Err.Number & Err.Description
End If

'**********************************************************
' This must be set to the Admin Account on the the LDAP Target
'**********************************************************
Set oADsTargetContainer = oLDAP.OpenDSObject(strTargetLdapPath, _
"cn=Administrator,ou=Members,o=SRC", "password", 0)
If Err.Number < > 0 Then
Response.Write strFontStyle & Err.Number & Err.Description
End If

'**********************************************************
' oLDAP is not needed anymore; destroy...
'**********************************************************
Set oLDAP = Nothing

Response.Write " <table border=1 >"

For Each oADsOldUser In oADsSourceContainer
If LCase(oADsOldUser.Class) = "member" Then
Set oADsNewUser = oADsTargetContainer.Create("member", "cn=" & oADsOldUser.cn)

'***** You must at least migrate the GUID *****
oADsNewUser.Put "GUID", oADsOldUser.Guid
oADsNewUser.Put "givenName", oADsOldUser.givenName
oADsNewUser.Put "sn", oADsOldUser.sn
oADsNewUser.Put "userPassword", oADsOldUser.userPassword
oADsNewUser.Put "mail", oADsOldUser.mail

'***** You must at least migrate the GUID *****
' Add more variables if neccessary

'**********************************************************
' .SetInfo "sets" all the items we have "put" in the cache.
'**********************************************************
oADsNewUser.SetInfo
Response.Write " <tr > <td >"
'This error description is: "Cannot create a file when that file already exists"
If Err.Number = -2147024713 Then
Response.Write strFontStyle & "Member Already Exists."
End If
If Err.Number < > 0 Then
Response.Write strFontStyle & Err.Number & Err.Description
End If

Response.Write strFontStyle & oADsOldUser.cn & vbCrLf
Response.Write " </td > </tr >"
Set oADsNewUser = Nothing
End If
Next

Response.Write " </table >"

Set oADsSourceContainer = Nothing
Set oADsTargetContainer = Nothing
Set oADsOldUser = Nothing

Response.Write "Members Migrated..."
End Sub

% >

Views 4,989

Downloads 1,585

CodeID
DB ID

JeffSmith
26
Revisions

v1.0

Monday
April
23
2018
Tags