Finally! My messages are going through! OK.
First off, let me preface that I currently use the webservices (for flexibility.) If you're using a page in SmartEdit or just a standalone page on the server, you can still make use of RQL to achieve the same thing.
LOGGING IN (WEBSERVICES)
The guid is passed back as the response from the webservice, if successful. I'll use a .NET example (assuming you've added the webservice to your solution):
if (service == null)
{
service = new YourCompany.RedDot.CMS.RQL.SessionService.SessionService();
service.Timeout = SERVICE_TIMEOUT;
}
guid = service.Login(username, password);
Console.WriteLine("Successful login with loginid {0}", guid);
LOGGING IN (RQL)
The guid is passed back along with some information when you send the proper request:
Login Request:
<IODATA>
<ADMINISTRATION action="login" name="admin" password="password"/>
</IODATA>
Example response:
<IODATA>
<LOGIN guid="[!guid_login!]" server="MyServer"
serverguid="[!guid_server!]" userkey="[!key_user!]"
usertoken="[!key_token!]"/>
<USER guid="[!guid_user!]" name="admin" fullname="Admin" id="1"
flags1="0" flags2="32768" dialoglanguageid="ENU"
dialogtextdirection="" languageid="ENU" showstarthelp="0" lcid="1031"
navigationtype="0" preferrededitor="0" invertdirectedit="0">
<MODULES>
<MODULE guid="[!guid_module!]" id="cms" name="0">
<MODULES>
<MODULE guid="[!guid_module!]" id="smarttree" name="13769"/>
...
</MODULES>
</MODULE>
<MODULE guid="[!guid_module!]" id="ccs" name="0" repository="xcms1">
<MODULES>
<MODULE guid="[!guid_module!]" id="dms" name="13774"/>
...
</MODULES>
</MODULE>
...
</MODULES>
<LASTMODULES>
<MODULE project="[!guid_project!]" projectname="Project name"
id="smarttree" guid="[!guid_module!]" lastid="smarttree"
lastguid="[!guid_!]" last="0"/>
...
</LASTMODULES>
</USER>
</IODATA>
You're looking specifically for the value of guid attribute from that response.
OK. We've got our login guid. However, if our app ever crashes or leaves a session hanging, then we need to be able to log that stale session off! Unfortunately the only way to accomplish this is to increase the number of allowed concurrent sessions to 2 or more for the "RQL" user, so it can login and logoff the other concurrent sessions. Otherwise, you'll just receive an error back (from the webservices it says RDE101 if I recall correctly.)
So in order to do this, we have to perform the following (after logging in):
1. Get a list of all online users
2. Loop through and find the one that has the same username as you
3. Log that session off
STEP 1: List all online users:
<IODATA loginguid="[!guid_login!]">
<ADMINISTRATION>
<USERS action="connectlist"/>
</ADMINISTRATION>
</IODATA>
Example response:
<IODATA>
<USERS>
<USER guid="[!guid_user!]" id="1" name="name"
fullname="First name Last name" flags1="0" flags2="0"
email="na...@company.com" maxlevel="1" dialoglanguageid="ENU"
loginguid="[!guid_login!]" logindate="37551,3837384259"/>
moduleid="servermanager" intern="0"
moduledescription="Server Manager" projectname="Up-And-Away"
projectguid="[!guid_project!]"/>
...
</USERS>
</IODATA>
Note that you can specify a specific userguid element on the request to list all online users to retrieve only the concurrent sessions for that user. However, since we don't necessarily have the guid of the current user (if we used the webservices), then we'll just list all online users and look for our specific ones.
STEP 2: Loop through all users in that result set, and find the one that matches your username
I use the following process (actual snippet from a .NET wrapper I've worked on):
// In the Session class
List<User> users = User.ListOnline();
foreach(User sessionUser in users)
{
if (sessionUser.Name == username)
{
if (sessionUser.LoginGuid == guid)
{
this.user = sessionUser;
}
else if (logoutConcurrentInstances)
{
Logout(sessionUser);
}
}
}
As you can see, if you find the user with your name and your loginguid, that's you. Otherwise, if you have opted into logging out concurrent instances, log that user out (since they have the same username, but not the same login guid)
Finally,
STEP 3: Logout user
This one is pretty basic.
LOGGING OUT (Webservices):
Following the snippet from logging in via webservices, logging out is incredibly simple:
service.Logout(guid);
LOGGING OUT (RQL):
Request:
<IODATA loginguid="[!guid_login!]">
<ADMINISTRATION>
<LOGOUT guid="[!guid_login!]"/>
</ADMINISTRATION>
</IODATA>
Response:
<IODATA>
</IODATA>
And you're done! I hope this was helpful.
> ...
>
> read more »
On Dec 16, 4:51 pm, "Killingsworth, Chad A"
> ...
>
> read more »- Hide quoted text -