1

How can I with ArcObjects GRANT or REVOKE Privileges like SELECT, UPDATE on SDE FeatureClasses to/from Roles?

The equivalent in normal Oracle would be something like this:

GRANT SELECT ON SCHEMA.TABLE TO SOME_ROLE;
REVOKE SELECT ON SCHEMA.TABLE FROM SOME_ROLE;

I can't seem to find the interface to perform this task, and it may not exists?

My dream would be to have an Interface like this:

public interface IPrivilegeManager
{
    void Grant(string privilegeName, string schemaOwnerName, string featureClassName, string roleName);
    void Revoke(string privilegeName, string schemaOwnerName, string featureClassName, string roleName);
}

Related Q: For a SDE FeatureClasses list all Roles that have been Granted any Privileges on it, and which Privileges each Role have on it

  • Welcome to GIS Stack Exchange! As noted in your "question", you are actually asking two questions so I would recommend that you split them so that we can have a clean Q&A for each issue. – PolyGeo Jul 4 '13 at 9:21
  • thank you @PolyGeo for the comment and welcome. :) The Questions are very closely related, but i partially agree with you. I'm not sure what the Header should be for the two questions. – furier Jul 4 '13 at 9:58
  • I think exactly what you have next to Q1 and Q2 would be fine. – PolyGeo Jul 4 '13 at 10:16
  • I for one believe that splitting the questions actually brings more confusion rather than adds any real value. – Petr Krebs Jul 4 '13 at 16:08
2

You can obtain the name object for the given feature class and cast it to ISQLPrivilege, which allows you to enumerate, grant and revoke permissions.

E.g.:

var name = ((IDataset) featureClass).FullName;
var sqlPrivilege = name as ISQLPrivilege;
if (sqlPrivilege != null)
{
    sqlPrivilege.Grant("USER_OR_ROLE_NAME", (int) esriSQLPrivilege.esriSelectPrivilege, false);
}
  • Really? :D ill get right on testing this! If this works Ill burst into joy! – furier Jul 4 '13 at 11:36
  • What type is featureClass in your example, currently i have a list of all the featureClasses in type IFeatureClassName and im unable to cast to IDataset, but i can cast to IDatasetName – furier Jul 4 '13 at 11:55
  • 1
    In my snippet, it is of type IFeatureClass. So if you have a IFeatureClassName, you have the name the object already, so you can cast it directly to ISQLPrivilege. – Petr Krebs Jul 4 '13 at 11:57
  • 1
    Also, be sure to read the docs for ISQLPrivilege, especially the part about feature classes nested in a feature dataset. Privileges for those cannot be managed separately, but it needs to be done on the whole feature dataset. – Petr Krebs Jul 4 '13 at 11:58
  • I splitted the questions since your answer only answered the second question and not the first. – furier Jul 4 '13 at 14:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.