Question : How to export distributions lists from active directory

Hello
I am in need of exporting users from my many distro lists into a format that is readable. I used the following:
Set oRootDSE = GetObject("LDAP://RootDSE")
strBase   =  "<LDAP://" & oRootDSE.get("defaultNamingContext") & ">;"
strFilter = "(&(objectclass=group)(sAMAccountType=268435457));"
strAttrs  = "distinguishedName;"
strScope  = "subtree"
 
Set objConn = CreateObject("ADODB.Connection")
objConn.Provider = "ADsDSOObject"
objConn.Open "Active Directory Provider"
Set objRS = objConn.Execute(strBase & strFilter & strAttrs & strScope)
 
objRS.MoveFirst
Dim objGroup
While Not objRS.EOF
      Set objGroup = GetObject("LDAP://" & Replace(objRS.Fields(0).Value,"/","\/"))
      WScript.Echo "-------------------------------------------------------"
      WScript.Echo "Connected to group DN : " & objGroup.distinguishedName
      WScript.Echo "Group Name : " & objGroup.sAMAccountName
      WScript.Echo "Members...."
      groupMembers = objGroup.member
      If IsEmpty(groupMembers) Then
            'No groups.
      ElseIf (TypeName(groupMembers) = "String") Then
            echoDetails(Replace(groupMembers,"/","\/"))
      Else
          For Each strGroup In groupMembers
                echoDetails(Replace(strGroup,"/","\/"))
          Next
      End If
      WScript.Echo "-------------------------------------------------------"
      WScript.Echo ""
      objRS.MoveNext
Wend
 
Sub echoDetails(strMemberDN)
    'USE ONE OF THE THREE ECHO STATEMENTS HERE TO SUIT YOUR NEEDS...
     Set objMember = GetObject("LDAP://" & strMemberDN)
    'WScript.Echo "...." & objMember.givenName & " " & objMember.sn
    'WScript.Echo "...." & objMember.name
    WScript.Echo "...." & objMember.cn
End Sub


This pulls does what I need it to do as far as pulling up the users. But it opens them up in individual prompt boxes instead of putting them into a txt or csv... What would need added to make some sort of output?

I also tried this:

Dim objGroup, objExcel, iRow, strUser
Set objGroup = GetObject("LDAP://CN=Distribution List,ou=all_staff,dc=winningtech,dc=local")
Set objExcel = CreateObject("Excel.Application")
With objExcel
 .SheetsInNewWorkbook = 1
 .Workbooks.Add
 .Visible = True
 .Worksheets.Item(1).Name = mid(objGroup.Name, instr(1,objGroup.Name,"=") + 1 ) 'set Worksheet name to that of the DL
 irow=1
 For Each strUser in objGroup.Member
   Set objUser =  GetObject("LDAP://" & strUser)
   .Cells(iRow,1) = objUser.CN
   .Cells(iRow,2) = objUser.EmailAddress
   irow=irow + 1
Next
.Columns(1).entirecolumn.autofit
End With
Set objExcel = Nothing
Set objGroup = Nothing  


But got an error on line 3 stating that the object could not be found.. But there is excel installed.

Any ideas? This is rather important. Thanks.

Answer : How to export distributions lists from active directory

Unfortunately, as a programmer, I think I can 100% say that this functionality is built in to the application concerned (which is why you don't get it on every application).  In terms of turning it off I can find no method to allow this and I don't think it is possible.  The only thing you can prevent is windows using jump lists to show recently opened documents/websites.  Let me know if this is useful and I'll explain how to turn these off.  For application jump lists it looks like you're stuck with them I'm afraid.

Regards,

Ady
Random Solutions  
 
programming4us programming4us