[THIN] Re: Get client name in WI4

  • From: Ormond_Merino@xxxxxxx
  • To: thin@xxxxxxxxxxxxx
  • Date: Thu, 18 Aug 2005 14:48:33 -0400

Thanks Jim, that's awesome.

 

Here is the code to set the clientname as the hostname(not the username) of
the client machine. It might also be of use.

 

Again, this too is a derivation of ThinFan's code, so he should get most of
the props...

 

Note: this code will return the IP address (only the first octet because of
the split I'm doing) of the client machine unless you enable reverse dns
lookups in IIS using the command below.

Cscript.exe C:\inetpub\adminscripts\adsutil.vbs set
/w3svc/1/ROOT/EnableReverseDNS "TRUE"

 

 

// Create the clientName

                        String client = Request.UserHostName;

// split the string, removing the dns suffix. The FQDN could make the name
too long.

                  string[] client1 = client.Split('.');


                string clientName = client1[0];

            //write the hostname to the cookie, we're no longer reading the
cookie before creating the name, 

//but I had problems logging when I didn't write the name to the cookie

                deviceState.put(COOKIE_LOGIN_CLIENT_NAME, clientName); 

 

 

 

Regards,

Ormond Merino

 

  _____  

From: Jim Kenzig Kenzig.com [mailto:jkenzig@xxxxxxxxx] 
Sent: Thursday, August 18, 2005 2:02 PM
To: thin@xxxxxxxxxxxxx
Subject: [THIN] Re: Get client name in WI4

 

Ormond,

This is great..I turned it into an FAQ item on thethin.net so it is written
in the pages of history. Please look at

 

http://thethin.net/faqs2.cfm?id=478
<http://thethin.net/faqs2.cfm?id=478&category=3> &category=3

Let me know if I got this right.

 

PS: Are you any relation to Dag Merino the guy who designed thethin.net
logo?

Thanks

Jim Kenzig

http://thin.net <http://thin.net> 


Ormond_Merino@xxxxxxx wrote:

I haven't been able to determine what criteria it's using to check if a
clientname is unique... it may think that the client name is unique and is
bypassing the generateunique() statement. 

 

 

 <mailto:ormond_merino@xxxxxxx>  


  _____  


From: Evan Mann [mailto:emann@xxxxxxxxxxxxxxxxxxxxx] 
Sent: Thursday, August 18, 2005 1:26 PM
To: thin@xxxxxxxxxxxxx
Subject: [THIN] Re: Get client name in WI4

 

I have Workspace control enabled   I'm able to customize my setting without
any problems.  What I do have question about however is this.  My code is
setup as follows

 

 String clientName = MPSClientNames.fromAccessToken( accessToken );
     String[] client = clientName.Split('-');    
      clientName = client[1];
    if (!MPSClientNames.isValidUniqueName(clientName)) {
        if( config.getWorkspaceControlConfiguration().getEnabled() ) {
            clientName = MPSClientNames.generateUnique();
            deviceState.put(COOKIE_LOGIN_CLIENT_NAME, clientName); //
Remember for future sessions
        } else {
            // Use the old client name format when Workspace Control is
disabled for
            // compatibility (MPS/U and MF1.8 need the old format to do
roaming
            // reconnection).
            clientName = MPSClientNames.fromAccessToken( accessToken );

The 2nd if statement is checking for workspace control being enabled
correct?  And if so, it's modifying the clientnNme.  Well, the code you gave
me, which alters the clientName prior to the 2nd if statement is still
holding true.  Shouldn't the clientName be altered to whatever
MPSClientNames.generateUnique() is doing?

 


  _____  


From: thin-bounce@xxxxxxxxxxxxx [mailto:thin-bounce@xxxxxxxxxxxxx] On Behalf
Of Ormond_Merino@xxxxxxx
Sent: Thursday, August 18, 2005 1:12 PM
To: thin@xxxxxxxxxxxxx
Subject: [THIN] Re: Get client name in WI4

On another note...I was not the person who originally submitted this code.
It was ThinFan I believe. I took his example and expanded on it to use the
hostname of the client machine as the client name. I wasn't able to test it
fully because we're not using workspace control, but it did correctly set
the clientname as expected.

 

So, Workspace Control is functioning correctly with his code? That's good to
hear.

 

Regards,

Ormond Merino

 <mailto:ormond_merino@xxxxxxx>  

 


  _____  


From: Ormond_Merino@xxxxxxx [mailto:Ormond_Merino@xxxxxxx] 
Sent: Thursday, August 18, 2005 12:45 PM
To: thin@xxxxxxxxxxxxx
Subject: [THIN] Re: Get client name in WI4

 

You could try this...

 

   // Always determine the client name from the user's identity 

    String clientName = MPSClientNames.fromAccessToken( accessToken ); 

              String[] client = clientName.Split('-');    

                        clientName = client[1];

                        deviceState.put(COOKIE_LOGIN_CLIENT_NAME,
clientName); 

      deviceInfo.setDetectedAddress( Request.UserHostAddress );

    deviceInfo.setClientName( clientName );

 

 

Regards,

Ormond Merino

 


  _____  


From: Evan Mann [mailto:emann@xxxxxxxxxxxxxxxxxxxxx] 
Sent: Thursday, August 18, 2005 12:13 PM
To: thin@xxxxxxxxxxxxx
Subject: [THIN] Get client name in WI4

 

Just wanted to pass along that I tried this method below, which was posted
by another person (forget who, sorry!) and it works nicely thus far.  

All the printers now show up as domain-username.  That doesn't match exactly
with what was mentioned below as the original poster said they only see the
username.  I would ideally like ONLY the username, so can anyone tell me
what I should tweak to have it show only the username?  Perhaps it's a back
end setting and not something I need to change in the code?

--------------- 
I saw that someone already responded with the published Citrix 
solution, however that method disables workspace control. 

We therefore took a different route:  We modified the Session.cs file 
and left workspace control enabled.  Now we get User Name (not 
domain-username) for the Client ID AND we have workspace control 
still. 

We are still testing this method to assure no other problems, but so 
far it looks good. 

Session.cs info: 

Here is the original Code 

Change these lines to decide how the client name is chosen: 

    // Get the client name to use (create a new one, if necessary) 
    String clientName = (String)deviceState.get(COOKIE_LOGIN_CLIENT_NAME); 
    if (!MPSClientNames.isValidUniqueName(clientName)) { 
        if( config.getWorkspaceControlConfiguration().getEnabled() ) { 
            clientName = MPSClientNames.generateUnique(); 
            deviceState.put(COOKIE_LOGIN_CLIENT_NAME, clientName); //
Remember for future sessions 
        } else { 
            // Use the old client name format when Workspace Control is
disabled for 
            // compatibility (MPS/U and MF1.8 need the old format to do
roaming 
            // reconnection). 
            clientName = MPSClientNames.fromAccessToken( accessToken ); 
        } 
    } 

For example, replacing the lines above with this should always use the 
client name derived from the username: 

    // Always determine the client name from the user's identity 
    String clientName = MPSClientNames.fromAccessToken( accessToken ); 
------------------------ 


  _____  


This message and any attachments are intended only for the use of the
addressee and may contain information that is privileged and confidential.
If the reader of the message is not the intended recipient or an authorized
representative of the intended recipient, you are hereby notified that any
dissemination of this communication is strictly prohibited. If you have
received this communication in error, notify the sender immediately by
return email and delete the message and any attachments from your system. 

Other related posts: