<HTML><HEAD><TITLE>Workstation User Account migration</TITLE> <META http-equiv=Content-Type content="text/html; charset=iso-8859-1"><LINK href="files/v2006.css" type=text/css rel=stylesheet> <BODY leftMargin=0 topMargin=30 marginwidth="0" marginheight="0"> <CENTER> <% ' ------------------------------------------------------------------------ Const ADS_PROPERTY_CLEAR = 1 Const SOURCE_OU="ou=NT Users,ou=NT,dc=fr,dc=erm,dc=int" Const TARGET_OU="ou=SUPPORT SERVICES,dc=fr,dc=erm,dc=int" Const HOMES_PATH="\\frsrvfil0001\USERS\" Const PROFILES_PATH="\\frsrvfil0001\PROFILES\" Const ADMIN_HOMES_PATH_SOURCE="\\frsrvfil0001\U$\NT\" Const ADMIN_PROFILES_PATH_SOURCE="\\frsrvfil0001\P$\NT\" Const ADMIN_HOMES_PATH_DEST="\\frsrvfil0001\U$\" Const ADMIN_PROFILES_PATH_DEST="\\frsrvfil0001\P$\" Const SCRIPT_NAME="ntuser_to_xp.asp" Dim State State="Init" Dim OU, Member If Request.QueryString("login") <> "" Then ' Affichage formulaire pour modif du compte State="Info" End If If Request.Form("login") <> "" Then ' On a cliqué sur OK pour valider le formulaire State="Modify" End If ' ------------------------------------------------------------------------ %> <TABLE cellSpacing=0 cellPadding=1 width=500 align=center bgColor=#26333e border=0> <TBODY> <TR> <TD> <TABLE cellSpacing=0 cellPadding=1 width=500 align=center border=0> <TBODY> <TR bgColor=#f0f3f5> <TD width=160 valign="top"><IMG height=116 src="files/man_portable.jpg" width=160> </TD> <TD width=302 bgColor=#e5ebef> <% If State="Init" Then '----------------------------------------------------------------------------------- ' Listing of the NT Users '----------------------------------------------------------------------------------- %> <TABLE cellSpacing=4 cellPadding=4 width="100%" align=center border=0> <TBODY> <TR> <TD class=medium colSpan=3 height=22> <% 'Response.Write(SOURCE_OU & "<BR>") %> Please select the NT 4.0 Workstation user account to migrate </TD></TR> <TR> <TD class=td11 height=22> <% Set OU = GetObject("LDAP://" & SOURCE_OU) OU.Filter = Array("user") For Each Member In OU ' Bug with the SMS Account ?? If Member.Name <> "CN=SMSService" Then If Member.AccountDisabled = 0 Then Response.Write("<A HREF=""" & SCRIPT_NAME & "?login=" & Server.URLEncode(Member.Name) & """>" & Member.FullName & "</A><BR>") End If End If Next %> </TD> </TR> </TBODY></TABLE> <% End If %> <% If State="Info" Then '----------------------------------------------------------------------------------- ' Information page about the NT Users '----------------------------------------------------------------------------------- %> <FORM method=post> <TABLE cellSpacing=4 cellPadding=4 width="100%" align=center border=0> <TBODY> <TR> <TD class=medium colSpan=2 height=22> <% Response.Write("Windows NT 4.0 User Account Migration") %> </TD></TR> <% Sub TabRow(v1,v2) Response.Write("<TR class=td11 height=16><TD><B>" & v1 & "</B>") Response.Write("<TD>" & v2 & "</TD>") Response.Write("</TD></TR>") End Sub Set Member = GetObject("LDAP://" & Request.QueryString("login") & "," & SOURCE_OU) TabRow "User Name",Member.FullName TabRow "NT Login",Member.sAMAccountName TabRow "Login Script", Member.LoginScript & " (to delete)" TabRow "Profile Path", Member.Profile TabRow "New Path",PROFILES_PATH & Member.sAMAccountName TabRow "Home Folder", Member.HomeDirectory TabRow "New Path",HOMES_PATH & Member.sAMAccountName ' Liste des OU dans SUPPORT SERVICES Dim OUSuppServices, Entity, BoxList Set OUSuppServices=GetObject("LDAP://" & TARGET_OU) OUSuppServices.Filter = Array("organizationalUnit") BoxList="<SELECT NAME=""entity"">" For Each Entity in OUSuppServices BoxList= BoxList & "<OPTION VALUE=""" & Entity.Name & """>" & Mid(Entity.Name,4) & "</OPTION>" Next BoxList=BoxList & "</SELECT>" TabRow "Organizational Unit",BoxList %> </TBODY></TABLE> <BR> <INPUT name=login type=hidden value=<% Response.Write(Member.sAMAccountName) %> > <INPUT type=image height=18 alt="GO !" width=15 src="files/submit.gif" value=login border=0 name=ok>  Cliquer ici pour migrer ce compte.<BR><BR> ATTENTION, l'utilisateur ne doit pas être connecté ! <% Response.Write("<BR><BR><A HREF=""" & SCRIPT_NAME & """>" & "Cliquer ICI pour annuler" & "</A><BR>") %> </FORM> <% End If %> <% If State="Modify" Then '----------------------------------------------------------------------------------- ' Migration of the NT Users '----------------------------------------------------------------------------------- Sub dirMoveTree(source, dest) Response.Write "Deplacement de <B>" & source & " vers " & dest & "</B><BR>" Dim Folder,File,SubFolder set Folder=fso.GetFolder(source) For Each File In Folder.Files Response.Write File.Name & " File -> " & dest & "<BR>" file.move dest & "\" Next For Each SubFolder In Folder.SubFolders Response.Write SubFolder.Name & " Folder -> " & dest & "<BR>" SubFolder.move dest & "\" Next End Sub %> <CENTER> Windows NT 4.0 User Account Migration<BR><BR> <% ' Modification des proprietes l'utilisateur dans AD Set Member = GetObject("LDAP://" & Request.QueryString("login") & "," & SOURCE_OU) ' ADS_PROPERTY_CLEAR Member.PutEx 1, "scriptPath", 0 Member.SetInfo Member.Put "profilePath", PROFILES_PATH & Member.sAMAccountName Member.Put "homeDirectory", HOMES_PATH & Member.sAMAccountName ' Member.SetInfo ' Response.Write("Utilisateur <B>" & Member.sAMAccountName & "</B> Modifié dans AD<BR><BR>") ' Deplacement dans le bon conteneur Set OU = GetObject("LDAP://" & "OU=Users," & Request.Form("entity") & "," & TARGET_OU) OU.MoveHere "LDAP://" & Request.QueryString("login") & "," & SOURCE_OU, Request.QueryString("login") Response.Write("Utilisateur <B>" & "LDAP://" & Request.QueryString("login") & "," & SOURCE_OU & "</B> Deplacé dans " & "LDAP://" & "OU=Users," & Request.Form("entity") & "," & TARGET_OU & "<BR><BR>") DIM fso, File, Folder, SubFolder Set fso = CreateObject("Scripting.FileSystemObject") ' Creation des repertoires cible fso.CreateFolder(ADMIN_HOMES_PATH_DEST & Request.Form("login")) fso.CreateFolder(ADMIN_PROFILES_PATH_DEST & Request.Form("login")) ' Deplacement des données dirMoveTree ADMIN_HOMES_PATH_SOURCE & Request.Form("login"),ADMIN_HOMES_PATH_DEST & Request.Form("login") dirMoveTree ADMIN_PROFILES_PATH_SOURCE & Request.Form("login"),ADMIN_PROFILES_PATH_DEST & Request.Form("login") ' Applications des ACLs, en arriere plan car ca peut etre long ! Response.Write("<BR>Creation du script d'application des ACLs C:\Inetpub\wwwroot\techcity\xcacls_" & Request.Form("login") & ".cmd<BR><BR>") Set server_shell = Server.CreateObject("wscript.shell") server_shell.Run "cmd /c echo echo Excecution Cacls >C:\Inetpub\wwwroot\techcity\xcacls_" & Request.Form("login") & ".cmd 2>&1",,1 server_shell.Run "cmd /c echo xcacls.exe """ & ADMIN_HOMES_PATH_DEST & Request.Form("login") & """ /T /C /G SYSTEM:F ADMINISTRATORS:F FR-ERM\" & Request.Form("login") & ":C /Y >>C:\Inetpub\wwwroot\techcity\xcacls_" & Request.Form("login") & ".cmd 2>&1",,1 server_shell.Run "cmd /c echo xcacls.exe """ & ADMIN_PROFILES_PATH_DEST & Request.Form("login") & """ /T /C /G SYSTEM:F ADMINISTRATORS:F FR-ERM\" & Request.Form("login") & ":F /Y >>C:\Inetpub\wwwroot\techcity\xcacls_" & Request.Form("login") & ".cmd 2>&1",,1 ' server_shell.Run "C:\Inetpub\wwwroot\techcity\xcacls.cmd >C:\Inetpub\wwwroot\techcity\xcacls.log 2>&1",,1 Response.Write("<BR>Les ACLs seront appliquee dans 5 min (scheduled)...<BR><BR>") Response.Write("Attendre egalement la fin de replication de AD ...<BR><BR>") Response.Write("<BR>Terminé !<BR>") %> <% Response.Write("<BR><BR><A HREF=""" & SCRIPT_NAME & """>" & "Cliquer ICI pour quitter" & "</A><BR>") %> </CENTER> <% End If %> </TD></TR> </TBODY></TABLE></TD></TR> </TBODY></TABLE></CENTER></BODY></HTML>
You need to create an account or log in to post comments to this site.