'This installer is for a quick import of LDIF Files into ADAM
'Developed by Jeremy Edmiston | Point Loma Nazarene University
'Created 6/30/05 Revised 12/23/06

'Notes:
'   This installer will prompt for an LDIF file, then import
'   the file contents into ADAM.


'Instantiate WSH Script
set wshShell = Wscript.createobject("wscript.shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")

'Check Windows Directory
if objFSO.folderexists("C:\Windows") then
        ADAM= "C:\Windows\ADAM\"
        'Call the first SubRoutine to start Installer
        BrowseWithcommonDialog
elseif objFSO.folderexists("C:\WINNT") then
        ADAM= "C:\WINNT\ADAM\"
        'Call the first SubRoutine to start Installer
        BrowseWithcommonDialog
else
        msgbox "Cannot find ADAM"
end if

'SubRoutines *******************************************************************

Sub BrowseWithCommonDialog()

        Set objDialog = CreateObject("UserAccounts.CommonDialog")
        objDialog.Filter = "LDIF Files|*.ldf"
        objDialog.FilterIndex = 1
        objDialog.InitialDir = "."
        nResult = objDialog.ShowOpen

        If nResult = 0 Then
                MsgBox "Cancel"
        Else
                'msgbox objdialog.filename
                InstallLDF(objDialog.FileName)
        End If

        'For Hardcoded Installer
        'InstallLDF("W2Statements.ldf")
       

End Sub

Sub InstallLDF(LDIF)

        wshShell.run "%COMSPEC% /k " & ADAM & "ldifde.exe  -i -f " & """" & LDIF & """" & " -c ""CN=Schema,CN=Configuration,CN=X"" ""#schemaNamingContext"" -k -s localhost -v"

end sub