No subject


Thu Jan 12 21:14:02 GMT 2006


and if I could remember where the pieces came from, I'd give full
credit.  Sorry :(.

This should work on any domain.  Let me know if there are bugs/etc.

I'm still ironing out my cron job, but this was a rather exciting fix
for me, that I couldn't wait to share.

----------------------------------
default.asp
----------------------------------
<%
Dim rootDSE, domainObject
Set rootDSE=GetObject("LDAP://RootDSE")
domainContainer = rootDSE.Get("defaultNamingContext")
Set domainObject = GetObject("LDAP://" & domainContainer)
Set fs = CreateObject ("Scripting.FileSystemObject")
ExportUsers(domainObject)
Set oDomain = Nothing


Sub ExportUsers(oObject)
        Dim oUser
        For Each oUser in oObject
                Select Case oUser.Class
                        Case "user"
                                If oUser.mail <> "" then

                                        for each email in
oUser.proxyAddresses 
                                                print_email(email)
                                        next            	
                                End if 
                        	
                        Case "group"
                                If oUser.mailNickname <> "" then

                                        for each email in
oUser.proxyAddresses 
                                                print_email(email)
                                        next            	
                                End if
	
                        Case "organizationalUnit" , "container"
                                If UsersGroupsinOU (oUser) then 
                                        ExportUsers(oUser)
                                End if 
                End select
        Next
End Sub

Function print_email(email)
        if Instr(email, "SMTP:") <> 0  or Instr(email, "smtp:") <> 0
then
                dim n, e
                ' locate the ":"
                n = InStr(1, email, ":", 1)

                ' and chop it off
                e = Right(email, Len(email) - n)	

                ' write the email address, two tabs, and a LF
                response.write(e & Chr(9) & Chr(9) & "ACCEPT" & Chr(10))

        end if
end function

Function UsersGroupsinOU (oObject)
        Dim oUser
        UsersGroupsinOU = False
        for Each oUser in oObject 
                Select Case oUser.Class
                        Case "organizationalUnit" , "container"
                                UsersGroupsinOU = UsersGroupsinOU(oUser)
                        Case "user"
                                UsersGroupsinOU = True
                        Case "group"
                                UsersGroupsinOU = True
                End select
        Next
End Function

%>

------------------------ MailScanner list ------------------------
To unsubscribe, email jiscmail at jiscmail.ac.uk with the words:
'leave mailscanner' in the body of the email.
Before posting, read the MAQ (http://www.mailscanner.biz/maq/) and
the archives (http://www.jiscmail.ac.uk/lists/mailscanner.html).

Support MailScanner development - buy the book off the website!




More information about the MailScanner mailing list