Page 1 of 1 1
Topic Options
#119074 - 2004-05-05 08:48 PM MFCOM Scripting
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
Hey Guys...Im trying to take some sample vbscript for the MFCOM (MetaFrame COM) object and turn them into kix. Any assistance would be appreciated. Im having trouble on the initialization portion for some reason. Its probably just some syntax thing on my end.

Here is one of the VBScript samples...
Code:
<package>
<job id="LUsers">
<comment>

File: LUsers.wsf
Description: List user count per each server in the farm.
Requirements: WSH 5.5 or higher.

Copyright (c) 2002 Citrix Systems, Inc.

</comment>
<runtime>
<description>
List user count per each server in the farm.
</description>
<example>
CScript //nologo LUsers.wsf
</example>

</runtime>
<reference object="MetaFrameCOM.MetaFrameFarm"/>
<script language="VBScript">

Dim theFarm, aServer, aSession, Count, SessionList

Set theFarm = CreateObject("MetaFrameCOM.MetaFrameFarm")

'
' Initialize the farm object.
'

theFarm.Initialize(MetaFrameWinFarmObject)

For Each aServer In theFarm.Servers
Set SessionList = aServer.Sessions
For Each aSession In SessionList
Count = SessionList.Count
Exit For
Next
Count = Count - 5
WScript.Echo aServer.ServerName & ", " & Count
Next

WScript.Echo "Press ENTER to exit..."
WScript.StdIn.Read(1)

</script>
</job>
</package>



And here is a short script I am trying to write to get the users IP address...
Code:
$ctxfarm = CreateObject("MetaFrameCOM.MetaFrameFarm")
If @Error <> 0
? "Error occurred while creating the farm object"
? ""+@Error+" - "+@SError
Endif

$ctxfarm.Initialize(MetaFrameWinFarmObject)
If @Error <> 0
? "Error occurred while initializing the farm object"
? ""+@Error+" - "+@SError
Endif

For Each $ctxserver in $ctxfarm.servers
If $ctxserver = @WkSta
For Each $ctxsession in $ctxserver.sessions
If $ctxsession.UserName = @UserID
? "You Are....."
? "Client Name : "+$Session.ClientName
? "Client Addr : "+$Session.ClientAddress
Endif
Next
Endif
Next

get $



I keep getting a Type Mismatch error when I try to do the .initialize. Any ideas?

Top
#119075 - 2004-05-05 08:51 PM Re: MFCOM Scripting
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
Ahhh...Well after looking at some other type mismatch posts on here it seems I probably need to somehow find the numeric value for the initialization type.
Top
#119076 - 2004-05-05 09:32 PM Re: MFCOM Scripting
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
OK...Atleast found the value for the Farm enumeration, so this works to get all kinds of client info whe loggin into a citrix server.

Code:
$ctxfarm = CreateObject("MetaFrameCOM.MetaFrameFarm")
If @Error <> 0
? "Error occurred while creating the farm object"
? ""+@Error+" - "+@SError
Endif

$ctxfarm.Initialize(1)
If @Error <> 0
? "Error occurred while initializing the farm object"
? ""+@Error+" - "+@SError
Endif

For Each $ctxserver in $ctxfarm.servers
If $ctxserver.ServerName = @WkSta
For Each $ctxsession in $ctxserver.sessions
If $ctxsession.UserName = @UserID
? "You Are....."
? "Client Name : "+$ctxsession.ClientName
? "Client Addr : "+$ctxsession.ClientAddress
Endif
Next
Endif
Next

get $



Have also found problems with it working for non-admin users though so it may be useless.

Top
#119077 - 2004-07-28 08:59 PM Re: MFCOM Scripting
Steve_B Offline
Fresh Scripter

Registered: 2004-02-04
Posts: 15
Shane (or anyone),

I like your MFCOM-to-KIX code here. I'd like to implement so I can use in a login script to determine if a user has multiple sessions running. It works great but only for Admins (as you'd noted in the previous post).

Just wondering if you ever got around the Admin limitation for MFCOM?!?

Thanks for any help.
Steve

Top
#119078 - 2004-07-29 12:31 AM Re: MFCOM Scripting
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
umm as far as i know it was a limitation in the mfcom itself. I have not tried anything using the newest version of 'presentation server 3.0' though. maybe they fixed it. something worth looking into atleast.
Top
#119079 - 2004-08-11 08:01 PM Re: MFCOM Scripting
MIRU Offline
Lurker

Registered: 2004-08-11
Posts: 1
Hi guys
As MPS3.0 is now the standard for Metaframe implementation you can grant the Citrix Administrative Rights to a User Group without having them the right to open the CMC and change settings. Especially you can grant them the only one needed right "View Session Information" which doesn't affect your security at this point. This permission allows you to run such scripts and enumerate the session information. Below my little version to enumerate the Clientlocation written in WSH:

Function funcLocationCheck()
'On Error Resume Next

Set oMFFarm = CreateObject("MetaFrameCOM.MetaFrameFarm")

' Initialize the farm object.
oMFFarm.Initialize 1
For Each oICASession In oMFFarm.Sessions
If oICASession.UserName = sUser Then
'WScript.Echo "Client IP: " & oICASession.ClientAddress
sClientIP = oICASession.ClientAddress
If InStr(sClientIP, "192.168.2") Or _
InStr(sClientIP, "192.168.1")Then
'WScript.Echo "Trusted Subnet!"
funcLocationCheck = True
End If
End If
Next

End Function


Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 515 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.054 seconds in which 0.024 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org