Retrieving existing login guid on RDError101

146 views
Skip to first unread message

Kareem

unread,
Jan 2, 2009, 8:29:27 AM1/2/09
to RedDot CMS Users
I'm using the RQL webservice to login and query RedDot. The problem I
have is when a user attempts to login but already have a session in
RD.
I get an RDError101. I would like to present the user with an option
to logout the other session and login anyways.

Its mentioned here that the existing login guid is retrievable, but I
can't figure out how.
http://groups.google.com/group/RedDot-CMS-Users/msg/4fb33dca64453ad1

The RDError101 is thrown in a SoapException. I don't actually get an
xml response from the webserver.

Does anyone know how to retrieve the existing login guid in this
scenario?

bushland25

unread,
Jan 2, 2009, 2:08:26 PM1/2/09
to RedDot CMS Users
If you are launching the script from a RedDot page that you are
currently logged into, all the login information is stored inside ASP
session variables. So, you can basically just read those session
variables to get the current login information. For example:

Dim sLogin
Dim sSession

sLogin = Session("LoginGuid")
sSession = Session("SessionKey")

That works well for me and I don't have to deal with figuring out
whether or not a user is already logged in when running the RQL.

For the scripts that I did need the login for, I just ignored the
error I received that said the user was logged in already. I could
then retrieve the session key and continue.

On Jan 2, 5:29 am, Kareem <kareemsul...@gmail.com> wrote:
> I'm using the RQL webservice to login and query RedDot. The problem I
> have is when a user attempts to login but already have a session in
> RD.
> I get an RDError101. I would like to present the user with an option
> to logout the other session and login anyways.
>
> Its mentioned here that the existing login guid is retrievable, but I
> can't figure out how.http://groups.google.com/group/RedDot-CMS-Users/msg/4fb33dca64453ad1

Kareem

unread,
Jan 2, 2009, 4:01:47 PM1/2/09
to RedDot CMS Users
I will be integrating something else into RedDot, so that session
information is good know. Thanks!

What I'm working on now though is an external tool, so I have to
retrieve all the information from the webservice.

How do you retrieve the session key when you don't have the login
guid? Its required in the IODATA element.
I'm also trying to retrieve the list of project for the user, which
needs the user guid. All that information is in the response for the
login action which is failing because the user is already logged in.

bushland25

unread,
Jan 2, 2009, 7:39:34 PM1/2/09
to RedDot CMS Users
Hmmm... Never worked with the webservice, and so I'd be a little lost
there... However, why don't you just ignore the error and then request
the session key? That is what I do in some of my other scripts...
Basically, I send the user guid and receive the 101 error because I am
currently logged in. I ignore the error and then send the same login
guid to get the session key and it works. Have you tried that? I then
use the user guid and the session key for all my other queries.
> > > scenario?- Hide quoted text -
>
> - Show quoted text -

Kareem

unread,
Jan 2, 2009, 8:56:29 PM1/2/09
to RedDot CMS Users
That's the problem. I have nothing more than a username and password
typed in by the user. I have no login guid, no user guid, and no
session key.
I can't do anything without a login guid, so I'm stuck.

akor

unread,
Jan 3, 2009, 5:31:20 AM1/3/09
to RedDot CMS Users
Hi Kareem,

Try this:

Public Function GetLoginGuid(strLoginUser,strLoginPass)
sRQLRequest = "<IODATA><ADMINISTRATION action='login' name='" &
strLoginUser & "' password='" & strLoginPass & "'/></IODATA>"
Set oRQLResponse = SendRQLRequest(sRQLRequest)
Set oNode = oRQLResponse.selectSingleNode("//LOGIN")
If oNode Is Nothing Then
Response.Write "ERROR: No LoginGUID found..."
Exit Function
End If
strLoginGUID = oNode.GetAttribute("guid")
If (sError="#RDError101") Then
Call LogOut(strLoginGUID)
Call GetLoginGuid(strLoginUser,strLoginPass)
End If
GetLoginGuid = strLoginGUID
Set oRQLResponse = Nothing
Set oNode = Nothing
End Function

I wrote this function for SOAP & WSDL. It logins you with the provided
credentials and grabs the Login GUID. If the User is already logged
in, it calls a LogOut function and the Login Function again.

Best,
-alex

bushland25

unread,
Jan 3, 2009, 7:39:34 PM1/3/09
to RedDot CMS Users
Oh! I am sorry I misunderstood your question. You can get the login
guids with an ASP script when you are logged in (i.e. Response.Write
Session("LoginGuid")) or you can look in the database to find it. The
database name is io_administration and the table name is io_usr. The
login guid is in the first column of that table. I generally use the
one for the admin user. Hope that helps.
> > > - Show quoted text -- Hide quoted text -

akor

unread,
Jan 4, 2009, 3:50:57 AM1/4/09
to RedDot CMS Users
Ah sorry, one thing more, you can get the session key then by this:
sRQLRequest = "<IODATA loginguid='" & strLoginGUID &
"'><ADMINISTRATION action='validate' guid='" & strLoginGUID &
"'><PROJECT guid='" & strProjectGUID & "' /></ADMINISTRATION></
IODATA>"

-alex

Kareem

unread,
Jan 5, 2009, 8:51:19 AM1/5/09
to RedDot CMS Users
hmm. The issue is using the login rql statement causes the webservice
to throw an exception, so I get zero information back on the logged
in user.
I'm only left with the username and password entered.
I'm running this from outside of reddot, so I don't have access to its
session variables.


Here's a thought. Is there some super user than can query all logged
in users and retrieve their session keys? Or perhaps I can make a user
just for this application.

Is there a query for a user by name to retrieve their current login
guid? I could then use that to log them out.

bushland25

unread,
Jan 5, 2009, 2:06:35 PM1/5/09
to RedDot CMS Users
How about this... You can check with RQL if a user is logged in using
the following:

<IODATA loginguid="[!guid_login!]">
<ADMINISTRATION>
<USERS userguid="[!guid_user!]" action="connectlist"/>
</ADMINISTRATION>
</IODATA>

You can get the user guid from the database as I mentioned in my prior
post. In your response XML, you will find the login guid if the user
is logged in. You can then retrieve the session variable or log the
user out before logging in.
> > > > > > - Show quoted text -- Hide quoted text -

Kareem

unread,
Jan 5, 2009, 2:51:17 PM1/5/09
to RedDot CMS Users
You mean this notation as a placeholder for me to put the value in
right? [!guid_login!]
I'll have nothing to fill it with. I don't know the login guid.

I'm starting to think this isn't possible. Surprising something so
basic isn't possible.

bushland25

unread,
Jan 5, 2009, 2:59:23 PM1/5/09
to RedDot CMS Users
Oh wonderful... I didn't even see that. Hmm...

Kareem

unread,
Jan 5, 2009, 3:01:58 PM1/5/09
to RedDot CMS Users
So maybe you can bash your head against your desk too. :)

bushland25

unread,
Jan 5, 2009, 3:42:39 PM1/5/09
to RedDot CMS Users
Yes, I shall :). Let me know if you come up with a solution.

bushland25

unread,
Jan 5, 2009, 3:52:22 PM1/5/09
to RedDot CMS Users
Are you using a .NET application to call the webservice? I think that
you are considering that you get a SoapException.

Anyway, why don't you have an ASP file on the server that simply
returns the session login. Since the ASP script doesn't crash if the
user is already logged in, it will always work. You can then have your
webservice first call the ASP file, get the session guid, and then
continue with your operations. I know it sounds like more than what's
needed, but I think it will work more effectively than anything else.

Kareem

unread,
Jan 5, 2009, 4:30:41 PM1/5/09
to RedDot CMS Users
That exactly what I'm doing, and yes, I'm getting a SoapException.I
wish it would just reply with an error in the response as opposed to
throwing a soap exception, but oh well.

I think you're idea will work. I was hoping for a solution without a
workaround, but that will have to do.
For now, I'm just telling the user to go logout themselves.
I have more issues with reddot to figure out now.

New post coming soon!

akor

unread,
Jan 6, 2009, 4:41:22 AM1/6/09
to RedDot CMS Users
Ok, so step by step:

1. Login with RQL

<IODATA>
<ADMINISTRATION action='login' name='admin' password='admin'/>
</IODATA>

1a. If user is not logged in yet or not all sessions are used, you'll
get
<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="DEU"
dialogtextdirection="" languageid="DEU" showstarthelp="0"
lcid="1031"
navigationtype="0" preferrededitor="0" invertdirectedit="0">
...
</USER>
</IODATA>

1b. If user is already logged in, you'll get

<IODATA>
<LOGINS>
<LOGIN guid="[!guid_login!]" loginguid="[!guid_login!]"
userguid="[!guid_user!]" lastdate="38562,6545023148"
lastactiondate="38562,6545023148" logindate="38562,6545023148"
intern="0" moduledescription=""/>
...
</LOGINS>
<USER guid="" id="0" flags1="0" flags2="0" dialoglanguageid="DEU"
dialogtextdirection="" languageid="" isservermanager="0"
showstarthelp="0"
lcid="1031"/>
</IODATA>

2. From both 1a and 1b grab the login guid: from <LOGIN guid="[!
guid_login!]"
Additionally, if 1b with RDError101, do a LogOut of the user and
Login again, so you end up with 1a.

3. Get the session with the login guid from 1a with RQL:
<IODATA loginguid="[!guid_login!]">
<ADMINISTRATION action="validate" guid="[!guid_login!]"
useragent="script">
<PROJECT guid="[!guid_project!]"/>
</ADMINISTRATION>
</IODATA>

Answere from server is

<IODATA>
<PROJECT guid="[!guid_project!]" name="project_name"
reddotstartpageguid="" flags="1" versioning="-1" testproject="0"
useexterneditor="0" externeditorurl="" requestexterneditortext=""
setnamesonlyinmainlanguage="0" rdeditorpreferred="0"
templaterelease="0" contentclassversioning="2"
wordeditorallowed="0"
liveserverguid="[!guid_liveserver!]" donotloadtexteditorinform="0"
mainlanguagevariantid="DEU" navigationmanager="1"/>
<USER guid="[!guid_user!]" userid="1" maxlevel="1"
isservermanager="-1" dialoglanguageid="DEU"
projectguid="[!guid_project!]" lm="-1" languagevariantid="DEU"
country="Germany" language="German" languagekey="ge"
lcid="1031" dialoglcid="1031" languagevariantlcid="1031"
rights1="-1" rights2="-1" rights3="-1" rights4="-1"
flags1="1040408"
flags2="15948"/>
<SERVER guid="[!guid_server!]" name="" key="[!key!]"/>
<LICENSE userguid="[!guid_user!]" projectguid="[!guid_project!]"
guid="[!guid_license!]" level="1" te="-1" lm="-1" id="smarttree"/
>
</IODATA>

Grab the session key from <SERVER ... key="xxxxx"

The function I posted before needs to be adjusted for your script.
A full working script could look like this:

strProjectGUID = "4DEF650A380D4218B915374023D35DB3"
sWSDLUrl = "http://192.168.50.50/cms/WebService/RDCMSXMLServer.WSDL"
strLoginUser = "admin"
strLoginPass = "admin"

Dim sRQLResponse, sError, sInfo
Dim strLoginGUID, strSessionKey, strUserGUID
Dim objXMLDOM, oSoapClient
Set objXMLDOM=Server.CreateObject("Microsoft.XMLDOM")

'Init the client to call the RedDot CMS WebService
Set oSoapClient = CreateObject("MSSOAP.SoapClient30")
oSoapClient.ClientProperty("ServerHTTPRequest") = True
oSoapClient.MSSoapInit2 sWSDLUrl, "", "", "", ""

Public Function SendRQLRequest(sRQLRequest)
'Execute the RQL and receive the response
sRQLResponse = oSoapClient.Execute(sRQLRequest, sError, sInfo)
Call objXMLDOM.LoadXML(sRQLResponse)
Set SendRQLRequest = objXMLDOM
End Function

Public Function GetLoginGuid(strLoginUser,strLoginPass)
sRQLRequest = "<IODATA><ADMINISTRATION action='login' name='" &
strLoginUser & "' password='" & strLoginPass & "'/></IODATA>"
Set oRQLResponse = SendRQLRequest(sRQLRequest)
Set oNode = oRQLResponse.selectSingleNode("//LOGIN")
If oNode Is Nothing Then
Response.Write "ERROR: No LoginGUID found..."
Exit Function
End If
strLoginGUID = oNode.GetAttribute("guid")
If (sError="#RDError101") Then
Call LogOut(strLoginGUID)
Call GetLoginGuid(strLoginUser,strLoginPass)
End If
GetLoginGuid = strLoginGUID
Set oRQLResponse = Nothing
Set oNode = Nothing
End Function

Public Function GetSessionKey(strLoginGUID, strProjectGUID)
sRQLRequest = "<IODATA loginguid='" & strLoginGUID &
"'><ADMINISTRATION action='validate' guid='" & strLoginGUID &
"'><PROJECT guid='" & strProjectGUID & "' /></ADMINISTRATION></
IODATA>"
Set oRQLResponse = SendRQLRequest(sRQLRequest)
Set oNode = objXMLDOM.SelectSingleNode("//SERVER")
If oNode Is Nothing Then
Response.Write "ERROR: No SessionKey found..."
Exit Function
End If
GetSessionKey = oNode.GetAttribute("key")
Set oRQLResponse = Nothing
Set oNode = Nothing
End Function

Public Function GetUserGuid(strSessionKey)
sRQLRequest = "<IODATA><PROJECT sessionkey='" & strSessionKey &
"'><USER action='sessioninfo'/></PROJECT></IODATA>"
Set oRQLResponse = SendRQLRequest(sRQLRequest)
Set oNode = objXMLDOM.SelectSingleNode("//USER")
If oNode Is Nothing Then
Response.Write "ERROR: No User found..."
Exit Function
End If
GetUserGuid = oNode.GetAttribute("guid")
End Function

Public Function LogIn(strLoginUser,strLoginPass)
strLoginGUID = GetLoginGuid(strLoginUser,strLoginPass)
strSessionKey = GetSessionKey(strLoginGUID, strProjectGUID)
strUserGUID = GetUserGuid(strSessionKey)
If (strLoginGUID <> "" AND strSessionKey <> "" AND strUserGUID <>
"" ) Then
LogIn = True
Else
LogIn = False
End If
End Function

Public Function LogOut(strLoginGUID)
sRQLRequest = "<IODATA loginguid='" & strLoginGUID &
"'><ADMINISTRATION><LOGOUT guid='" & strLoginGUID & "' /></
ADMINISTRATION></IODATA>"
Set oRQLResponse = SendRQLRequest(sRQLRequest)
LogOut = sRQLResponse
Set oRQLResponse = Nothing
End Function

Call LogIn(strLoginUser,strLoginPass)
'Do whatever you want to do with the script here
Call LogOut(strLoginGUID)

Best-
alex

Richard Hauer (5 Limes)

unread,
Jan 6, 2009, 7:23:13 AM1/6/09
to RedDot CMS Users
Hi Kareem,

The .Net-based SOAP interfaces make it impossible to get the return
value from the RQL call because of the exception. Essentially
the .Net web services in the "services" folder are there to support
the nav manager functionality and so when an error is returned from an
RQL call these web services don't return the IODATA response in the
SoapException's "detail" element - a bit rude really. To compensate
for this you need to create a method that makes the call directly so
that you can get at the result even though there is an exception.
In .Net 2.0 web service proxies generated by Visual Studio are written
into partial classes. You can create a file in your code that adds
methods to this partial class. You could create one thusly (C# -
"using" statements omitted):

public string GetLoggedInGuid( string userName, string password )
{
string postData = String.Format( @"<?xml version=""1.0""
encoding=""utf-8""?>
<soap:Envelope xmlns:soap=""http://schemas.xmlsoap.org/soap/
envelope/"" xmlns:soapenc=""http://schemas.xmlsoap.org/soap/
encoding/"" xmlns:tns=""http://tempuri.org/RDCMSXMLServer/
webservice/"" xmlns:types=""http://tempuri.org/RDCMSXMLServer/
webservice/encodedTypes"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-
instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
<soap:Body soap:encodingStyle=""http://schemas.xmlsoap.org/soap/
encoding/"">
<q1:Execute xmlns:q1=""http://tempuri.org/RDCMSXMLServer/
message/"">
<sParamA xsi:type=""xsd:string"">{0}</sParamA>
<sErrorA xsi:type=""xsd:string"">XMLServer.Execute: No data</
sErrorA>
<sResultInfoA xsi:type=""xsd:string"" />
</q1:Execute>
</soap:Body>
</soap:Envelope>", String.Format( @"&lt;IODATA&gt;&lt;ADMINISTRATION
action=&quot;login&quot; name=&quot;{0}&quot; password=&quot;{1}&quot;/
&gt;&lt;/IODATA&gt;", userName, password ) );

WebRequest req = WebRequest.Create( "http://reddot-cms/CMS/webservice/
RDCMSXMLServer.WSDL" );
req.Headers["SOAPAction"] = "\"http://tempuri.org/RDCMSXMLServer/
action/XmlServer.Execute\"";
req.Method = "POST";
req.ContentType = "text/xml; charset=utf-8";
req.ContentLength = postData.Length;
StreamWriter reqStreamWriter = new StreamWriter( req.GetRequestStream
() );
reqStreamWriter.Write( postData );
reqStreamWriter.Close();

WebResponse resp = req.GetResponse();
StreamReader respReader = new StreamReader( resp.GetResponseStream
() );
string result = respReader.ReadToEnd();
respReader.Close();
resp.Close();

XmlDocument xdResult = new XmlDocument();
xdResult.LoadXml( result );

XmlNode nResult = xdResult.SelectSingleNode( "//Result" );

XmlDocument xdResponse = new XmlDocument();
xdResponse.LoadXml( nResult.InnerText );

return xdResponse.SelectSingleNode( "//LOGIN" ).Attributes
["loginguid"].Value;
}


Note the WebRequest.Create method accesses the following URL:
http://reddot-cms/CMS/webservice/RDCMSXMLServer.WSDL

Obviously you will need to change reddot-cms to your actual server.
Also I think you have to select to install the SOAPToolkit option when
installing RedDot (I'm sure you can add it after).

At any rate, this is the "old school" web service which will return
the full IODATA response from RedDot in the nResult.InnerText, which
you can then use, as I have above, to retrieve the logonguid.

Non-trivial but not impossible.

HTH.

Regards,
Richard Hauer
====================
5 Limes Pty Limited
www.5Limes.com.au
> ...
>
> read more »- Hide quoted text -
Reply all
Reply to author
Forward
0 new messages