@ExpandNameList

Nice (but undocumented) function to expand a group:

@ExpandNameList( server:file; groupname )

Has been there since release 5, but it still works.

Updated 09.11.2011

Notice: @ExpandNameList will only work on Mail groups – ‘Access Control List only’ groups are not included (will return an empty array).

Sample script to resolve a list with mixed groups and functions:

%REM
Find all members in a group or list of groups and persons
Will also work when running on a local replica (but requires server access)
%ENDREM
Function getMembers( GroupOrNameList As Variant ) As Variant 

        Dim members As Variant 

        'find a server (use the homeserver if script is running on a local database)
        Dim server As Variant
        server = Evaluate(|@if( @subset( @dbname;1 ) = ""; @LocationGetInfo([HomeServer]); @subset( @dbname;1 ))|) 

        If Isarray( GroupOrNameList ) Then
                Forall member In GroupOrNameList
                        If Isempty( members ) Then
                                members = getMembers( member )
                        Else
                                members = Arrayappend( members, getMembers( member ))
                        End If
                End Forall
        Else
                members = Evaluate(|@ExpandNameList( "| & server( 0 ) & |":"names.nsf"; "| & GroupOrNameList & |" )|)
        End If 

                'fix problem with persons with an forward address on the person document
        Dim i As Integer
        Dim v As Variant
        For i=0 To Ubound(members)
                If lcase( Left(members(i), 3))<>"cn=" Then
                        v = Evaluate(|@NameLookup( [NoUpdate] ; "|+members(i)+|"; "fullname")|) 

                        if v( 0 ) = "" then
                                v = Evaluate(|@NameLookup( [NoUpdate] ; "|+strleftback( members(i), "@" )+|"; "fullname")|)
                        end if 

                        If Not Isempty(v) Then
                                members(i)=v(0)
                        End If
                End If
        Next 

                'remove duplets
        members = Arrayunique( members,5 ) 

                'return
        getMembers = members
End Function

Links

4 tanker om "@ExpandNameList"

  1. Is there a way around the forwarding address limitation that you know of? We are in a mixed Notes/Exchange environment and need the Notes name returned instead of the forwarding address.

  2. There is no easy way around. You have to loop all the results and check if it is a full qualified name (cn=….) – if it is not, you can get the right name by making a dblookup into the names.nsf (or using the @NameLookup function)

  3. Jakob Majkilde said…
    You have to loop all the results and check if it is a full qualified name (cn=….) – if it is not, you can get the right name by making a dblookup into the names.nsf (or using the @NameLookup function)

    2 problems with this approach.
    1. full qualified names can appear in the forwarding address field.
    2. There is no way of looking up a user's full name from their forwarding address. Forwarding address is not an indexed field.

Skriv et svar

Din e-mailadresse vil ikke blive publiceret. Krævede felter er markeret med *

*