This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DEVELOPERS FORUM - Temporary Administrators Permission while Executing SQL Querys.

Hrishikesh - Wednesday, May 15, 2013 11:59 AM:

Hi All,

I know how to set the Temporary Permission while Executing SQL Querys in Aras (C#).

below is the peace of Code where i Temporary assign the Permission to Administrators and after 

executing the SQL Query, I revoke the Permission.

 

Aras.Server.Security.Identity qpIdentity = Aras.Server.Security.Identity.GetByName("Administrators");

bool PermissionWasSet = Aras.Server.Security.Permissions.GrantIdentity(qpIdentity);    

var sqlstr = "";  // the SQL Query  String
var result = inno.applySQL(sqlstr);

if (PermissionWasSet) Aras.Server.Security.Permissions.RevokeIdentity(qpIdentity);
Now the Question is i want the same behaviour in Javascript   where i Execute the SQL Query.
If the user is not Administrator the SQL Query wont execute.
so i want to give the Temporary permission to Administrator and after executing SQL query, i Revoke the Permission.
please suggest.
Thanks,
Hrishikesh



Brian - Wednesday, May 15, 2013 7:18 PM:

Hi Hrishikesh,

Can't do it directly in Javascript.

You will need to define a generic server method (see programmers guide) that can execute the actual query under the right permissions.

Let's say you define a server method called "ExecuteMySql".

In BLOCKED SCRIPT

var inn = this.innovator();
var body = "<sqlString>Select * from Part</sqlString>"
var result = inn.applyMethod("ExecuteMySql",body);

// now do something with the result.

In your server method:

Innovator inn = this.getInnovator();
string sqlString = this.getProperty("sqlString","");

// execute your code as before to run the query.

Item result = inn.applySQL(sqlString);

return result;

Hope this helps,

Brian.