With Win2k being released, most of the Windows community has been talking about Active
Directory. If you're using SiteServer P&M, you have also noticed that their are very
little finished tools available to manage Microsoft LDAP databases (such as SiteServer
P&M). This is supposed to change with Active Directory being included in Windows 2000.
Because, quite honestly doing migration with ASP could prove to be a little cumbersome.
Here is a simple script to migrate users from one SiteServer/LDAP database to another.
You must have ADSI 2.5 (ads.exe) installed on the machine this script will run on.
I have also successfully migrated from a Microsoft LDAP database to a UNIX OpenLDAP
database using a similar script.
<%
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://SourceLDAPMachine:1003/o=microsoft/ou=members"
'**********************************************************
' Enter the LDAP Target Members Path To Copy To...
'**********************************************************
' strTargetLdapPath = "LDAP://TargetLDAPMachine:389/dc=mycompany/dc=com"
strTargetLdapPath = "LDAP://TargetLDAPMachine:389/o=microsoft/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=microsoft", "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=microsoft", "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
%>