|
Written 01-21-2005
PFDavAdmin, a Microsoft Tool for helping to make mass changes or export permissions can come in handy. This parser allows me to parse a PFDavAdmin LegacyDN export so that it is in a simple readable format that can be filtered and emailed out.
Script Code:
'AUTHOR: CARLTON COLTER
'*****************************
'*** Declare Constants ***
'*****************************
Const FORREADING = 1
Const FORWRITING = 2
Const FORAPPENDING = 8
'*****************************
'*** Attach System Objects ***
'*****************************
Dim FSO
Set FSO = CreateObject("Scripting.FileSystemObject")
Dim LogFileName
Dim CSVFileName
LogFileName = InputBox("Please type the name of the PFDAVLog:")
CSVFileNAme = "Parsed " & LogFileName
'*****************************
'*** Open File ***
'*****************************
'* Check to see if file exists
If Not FSO.FileExists(LogFileName) Then
MsgBox "File " & LogFileName & " not found!", vbExclamation, "ERROR"
Wscript.Quit
End If
'* Open the File
Dim LogFile
Dim CSVFile
Dim Line
Dim LineArray
Dim AMax
Dim Temp
Dim TempArray
Dim FPath
Dim User
Dim DUser
Dim DPerm
Set LogFile = FSO.OpenTextFile(LogFileName, FORREADING)
Set CSVFile = FSO.OpenTextFile(CSVFileName, FORWRITING, TRUE)
'* Read the Log File and Interpret
do while LogFile.AtEndOfStream <> true
'* Read Line
Line = LogFile.ReadLine
'Remove NO From the Line!
Line = Replace(Line,vbTab&"NO","")
'Replace HTML Characters with REAL Chatacers
Line = Replace(Line,"%20"," ")
Line = Replace(Line,"%26","&")
Line = Replace(Line,"%23","#")
Line = Replace(Line,"%27","'")
'Split the line Tab Delimited
LineArray = Split(Line,vbTab)
AMax = UBound(LineArray)
if AMax > 2 then
if right(LineArray(1),Len("non_ipm_subtree"))<>"non_ipm_subtree" Then
'Get User and Folder Path
If InStrRev(LineArray(1), "mbx") <> 0 then
TPos = InStrRev(LineArray(1), "mbx")+4
else
TPos = 0
end if
Temp = Right(LineArray(1),Len(LineArray(1))-TPos)
If TPOS<>0 then
TempArray = Split(Temp,"/")
User=TempArray(0)
If UBound(TempArray)>0 then FPath = Mid(LineArray(1),TPos+Len(User),Len(LineArray(1)))
else
User = ""
FPath = Temp
end if
If Left(User,Len("SystemMailbox"))<>"SystemMailbox" then
'Get the Folder Permissions
For N = 0 to ((AMax-2)/2)
DUser = LineArray(N*2+2)
DPerm = LineArray(N*2+3)
if DPERM<>"None" then
if DUSER<>"NT AUTHORITY\ANONYMOUS LOGON" then
If USER<>"" then
CSVFile.WriteLine User & vbTab & FPath & vbtab & DUser & vbtab & DPerm
else
CSVFile.WriteLine FPath & vbtab & DUser & vbtab & DPerm
end if
end if
end if
Next
end if
end if
end if
Loop
LogFile.Close
CSVFile.Close
MsgBox "COMPLETE"
|
0 Comments