This blog is by design...

Thursday, June 02, 2005

VBSCRIPT - For all domain users, write all their Delegate information to a file

The following script will recurse (go through) your AD structure,
and for all user accounts it will take their Outlook delegate information
and write it out to a file. Until recently I didn't realize that delegate
information that was set inside the Outlook client was stored in AD, but
guess what. It is. Give it a try...

'*****************************************************
'you MAY NOT post this script on any other website
'you MAY post a link to the script, thus giving me my due credit for
'writing it.

Set objRootDSE = GetObject("LDAP://rootDSE")
Set objDomainRoot = GetObject("LDAP://"& _
objRootDSE.Get("defaultNamingContext"))

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objOutputFile = objFSO.CreateTextFile("c:\Delegates.txt", True)

For Each objItem in objDomainRoot
'wscript.Echo objItem.Name
If objItem.Class="organizationalUnit" Then
OURecurse objItem.ADSPath
end if

If objItem.Class="user" Then
'wscript.Echo objItem.name
ProcessUsers objItem
End If
Next

objOutputFile.Close
set objOutputFile = Nothing
set objRootDSE = Nothing
set objDomainRoot = Nothing
set objFSO = Nothing

wscript.Echo "All Done"


'***************************************************
Sub ProcessUsers(objUsers)
On Error Resume Next

'wscript.Echo objUsers.Name
set objPD = GetObject("LDAP://"& _
objUsers.distinguishedName)
objOutputFile.Writeline objPD.displayName
delegateList = objPD.GetEx("publicDelegates")
For Each Desc In delegateList
objOutputFile.Writeline Desc
Next
objOutputFile.Writeline

set objPD = Nothing

End Sub


'*************************************************
' This sub is responsible for going through the AD Structure

Sub OURecurse(objFirst)


Dim objOrgUnit, objItem

Set objOrgUnit = GetObject(objFirst)
For Each objItem in objOrgUnit
If objItem.Class="user" Then
'wscript.Echo objItem.Name
ProcessUsers objItem
End If

If objItem.Class="organizationalUnit" Then
'wscript.Echo objItem.Name
OURecurse objItem.ADSPath
End If
Next

Set objOrgUnit = Nothing

End Sub
'***************************************************

'you MAY NOT post this script on any other website
'you MAY post a link to the script, thus giving me my due credit for
'writing it.

10 Comments:

  • great script kris. thanks!

    By Anonymous Anonymous, at 6:06 PM  

  • Great script! When I ran this & then went into a particular user's mbx to verify what others' rights were (to contacts or inbox or whatever) they actually had none. So I was hoping your script could be modified to show the rights another user has right in the txt file. Any thoughts? Thx in advance!

    By Anonymous Anonymous, at 2:30 PM  

  • All I can say is awesome! Just what I needed and very simple! Thank you very much for your help. -Chris

    By Anonymous Anonymous, at 4:45 PM  

  • Great script Kris! I really appreciate it and this information wil be extremely helpful.

    Any chance you can include SIDS where users have been deleted? I am trying to clean up some delegate access that is causing a bunch of NDR's.

    By Blogger Chris, at 7:17 PM  

  • Great script. It helped me to solve the delegate issue. Thanks alot.

    By Anonymous daye, at 2:12 PM  

  • Is there a way to show what delegate rights have been allowed for each user to a particular mailbox?

    By Blogger Sean McGilvray, at 2:07 PM  

  • if wow gold and maple story mesos wow gold

    By Blogger rduht, at 2:13 AM  

  • mcloving this

    By Blogger SleekGeek, at 7:32 PM  

  • Thanks your contributions have help me a lot with many projects or my major.

    By Anonymous Generic Viagra, at 4:39 PM  

  • Keep up the good work. general health Read a useful article about tramadol tramadol

    By Anonymous Anonymous, at 8:59 AM  

Post a Comment

<< Home