Folder rights for user

16 views
Skip to first unread message

hirakp...@gmail.com

unread,
Aug 24, 2018, 10:48:31 AM8/24/18
to SmartAPI
How to retrieve folderrights for a user? 
example query:- 

<IODATA loginguid="[!guid_login!]" sessionkey="[!key!]">
  <MEDIA>
    <FOLDER action="load" guid="[!guid_folder!]"/>
  </MEDIA>
</IODATA>

folderrights: - Detailed authorizations for an Asset Manager for the user who executes the RQL.  

I didn't find anything that says how to execute RQL using current user object?

 

Jonas Jacobi

unread,
Aug 24, 2018, 11:19:50 AM8/24/18
to smar...@googlegroups.com

You can execute RQL yourself through Session.ExecuteRQL (or Project.ExecuteRQL)

XMLElement response = Session.ExecuteRQL(„<MEDIA><FOLDER … /></MEDIA>“, RQL.IODataFormat.SessionKeyAndLogonGuid);

If you want a string instead of an XMLElement, you can also use Session.ExecuteRQLRaw(...)

 

Dr. Jonas Jacobi

Technical Lead


cid:1CED22B6-B0AD-42DB-B967-5CC408FF6360@fritz.box



Mobile Lösungen, Apps und das Internet der Dinge


Ehnernstr. 157

26121 Oldenburg, Germany

 

jonas....@erminas.de

http://www.erminas.de


Registergericht: Amtsgericht Oldenburg, HRB 209480
Geschäftsführer: Hilmar Bunjes

--
More information about SmartAPI: http://www.smartapi.de
---
Sie erhalten diese Nachricht, weil Sie in Google Groups E-Mails von der Gruppe "SmartAPI" abonniert haben.
Wenn Sie sich von dieser Gruppe abmelden und keine E-Mails mehr von dieser Gruppe erhalten möchten, senden Sie eine E-Mail an smartapi+u...@googlegroups.com.
Wenn Sie in dieser Gruppe einen Beitrag posten möchten, senden Sie eine E-Mail an smar...@googlegroups.com.
Weitere Optionen finden Sie unter https://groups.google.com/d/optout.

hirakp...@gmail.com

unread,
Aug 24, 2018, 11:58:20 AM8/24/18
to SmartAPI
Hi,

Thanks for the reply.  I am trying something like this and I got the exception as attached in the file. If I use Project.ExecuteRQL I get folder rights 0 or -1 and I don't know what exactly it means, and Project.ExecuteRQL does not take 2 parameters.
private ISession ServerConnection()
        {
            var authData = new PasswordAuthentication("username", "Password");
            var url = "myURL";
            var login = new ServerLogin(url, authData);
            var session = SessionBuilder.CreateOrReplaceOldestSession(login);
         
            return session;
        }

 protected void Page_Load(object sender, EventArgs e)
        {

            using (var session = ServerConnection())
            {
                LIST_FOLDER_INFORMATION = @"<MEDIA><FOLDER action=""load"" guid=""{0}"" /></MEDIA>";
               
                 var output = session.ExecuteRQL(LIST_FOLDER_INFORMATION.RQLFormat(folder.Guid), RQL.IODataFormat.SessionKeyAndLogonGuid);
1.PNG
2.PNG

Hirak Patel

unread,
Aug 27, 2018, 10:01:12 AM8/27/18
to smar...@googlegroups.com
Hi Jonas, 

Is this anything wrong with the code because it is not working.

Thanks
Hirak

Jonas Jacobi

unread,
Aug 27, 2018, 10:34:30 AM8/27/18
to smar...@googlegroups.com

It looks good to me.

Can you see anything abnormal in the result string / RDCMS logs?

You could try using the ExecuteRQLRaw method instead, maybe something is malformed in the response.

A different (slightly hackis solution) to get the info would be to use reflection on a SmartAPI folder object, to read a the RQL-response-XmlElement, which is there but not publicly  visible:

var folder = project.Folders …;


var element = (XmlElement)

                folder.GetType()

                    .GetProperty("XmlElement")

                    .GetValue(folder, null);

 

 

 

Dr. Jonas Jacobi

Technical Lead


cid:1CED22B6-B0AD-42DB-B967-5CC408FF6360@fritz.box



Mobile Lösungen, Apps und das Internet der Dinge


Ehnernstr. 157

26121 Oldenburg, Germany

 

jonas....@erminas.de

http://www.erminas.de


Registergericht: Amtsgericht Oldenburg, HRB 209480
Geschäftsführer: Hilmar Bunjes

 

Hirak Patel

unread,
Aug 27, 2018, 10:56:43 AM8/27/18
to smar...@googlegroups.com
Hi,

As I mentioned earlier, if I use session object to execute ExecuteRQL/ExecuteRQLRaw, I get an exception as attached in last email. 

I get the following response when I execute the query you gave me.

<FOLDER hideintexteditor="0" folderrights="-1" dms="" description="" path="" savetype="0" catalog="1" foldertype="0" name="Assets" guid="2C8300467B224D4EAF720BD9E3F41C25"/>

what does the folderright="-1" and is that right for the user who execute it?

Thanks

Jonas Jacobi

unread,
Aug 27, 2018, 11:05:28 AM8/27/18
to smar...@googlegroups.com

Unfortunately the exception you have is very unspecific, but it looked like a response was read, so I thought, it might be malformed in some way.

I don’t know myself what folderrights=-1 means, maybe someone else reading this list does.

Otherwise you have to reverse engineer the RQL yourself e.g. by changing rights and watching the folderrights value change accordingly.

Hilmar Bunjes

unread,
Aug 27, 2018, 1:44:46 PM8/27/18
to smar...@googlegroups.com
Hirak,
the message "Unknown error while loading folder information" looks like an invalid guid.

folderrights="-1" is an invalid value according to the RQL documentation. The right there is the right for the currently logged in user.

Best
Hilmar

Hirak Patel

unread,
Aug 27, 2018, 3:41:36 PM8/27/18
to smar...@googlegroups.com
Hilmar,

Thanks for the reply. You are right. The exception is because of an invalid guid. I have hard coded the guid but it still returns -1 for folderrights.

LIST_FOLDER_INFORMATION = @"<MEDIA><FOLDER action=""load"" guid=""2C8300467B224D4EAF720BD9E3F41C25"" /></MEDIA>";
                var result = session.ExecuteRQLRaw(LIST_FOLDER_INFORMATION, RQL.IODataFormat.SessionKeyAndLogonGuid);

<FOLDER maxlistcount="2000" maxfilecount="0" folderrights="-1" rootfolderdescription="" description="" foldertype="0" versioning="0" dms="" rootfoldername="Assets" rootfolderguid="2C8300467B224D4EAF720BD9E3F41C25" sharedrights="2" linkedprojectguid="" linkedfolderguid="" savetype="0" catalog="1" foldername="Assets\" name="Assets" guid="2C8300467B224D4EAF720BD9E3F41C25"/>

Folder name is correct here in the output but issue is with folderrights.

Thanks
Hirak
Reply all
Reply to author
Forward
0 new messages