Version 1 of Tcom examples for Citrix

Updated 2013-02-04 16:53:35 by MHo

Here is an example which enumerates applications, which are published via Citrix. It worked many years but a while ago I had to deactivate the user and group enumeration (with if 0 clauses), because they lead to an uncatchable application crash (runtime requested termination).

Perhaps someone could help narrow this down?

# siehe auch: http://forums.citrix.com/thread.jspa?threadID=102245
proc citrixEnumApps_ {} {
     # momentan keine expliziten Fehlerabfangungen, keine args
     set farm [::tcom::ref createobject "MetaFrameCOM.MetaFrameFarm"]
     $farm Initialize 1
     set allApps [list ]
     ::tcom::foreach app [$farm Applications] {
        $app LoadData 1
        set srvr [list ]
        set thisApp [list [$app DistinguishedName]]
        if {[$app AppType] == 3} {
           # MetaFrameWinAppObject
           set appObj [$app WinAppObject]
           if {[$appObj PNAttributes] & 8} {
              # MFWinAppDesktop
              lappend thisApp "(published Desktop)"
           } else {
              lappend thisApp [$appObj DefaultInitProg]
           }
           ::tcom::foreach srv [$app Servers] {
              lappend srvr [$srv ServerName]
           }
           set srvr [lsort $srvr]; # 15.10.2008
        } elseif {[$app AppType] == 17} {
            # MetaFrameContentObject
            set appObj [$app ContentObject]
            lappend thisApp [$appObj ContentAddress]
        }
        set grps [list ]
        if 0 {
        ::tcom::foreach grp [$app Groups] {
           lappend grps [$grp GroupName]
        }
        set grps [lsort $grps]; # 15.10.2008
        }
        set user [list ]
        if 0 {
        ::tcom::foreach usr [$app Users] {
           lappend user [$usr UserName]
        }
        set user [lsort $user]; # 15.10.2008
        }
        lappend thisApp $grps $user $srvr
        lappend allApps $thisApp
     }
     return $allApps
}