Programatically Check if the logged in user is in the Administrators group in Project Server (C#, VS2010)

Hi I would like to be able to check if the logged in user is a member of the administrator group programatically through c#
I know that I can get the user's GUID / check if they are actually a user in project server (resource table in reporting DB) but I am having trouble finding out how to programatically check if they are a member of the "Administrators" group.
Could somebody please provide a code sample of how to check if a user is in the administrators group when you have their GUID or username or name?
I did not see a table in the reporting DB that has this so I am guessing this has to be done through the PSI..
Thanks in advance!
BTW.. i am just wondering is there a way to check each groups permission levels? was wondering that if it is possible, what is the best way to implement a similar security model to that of the actual project server 2010

hi Amit :) I ended up finding the answer myself before you posted here but thank you for your reply anyways, it is basically the same thing that I did.
This is what I ended up doing :) Basically I have three different types of users configured in my web.config - admins, readwrite users, and read only users. In my code here I loop through and find out who the person is. Based on what group they are in I
can later show/hide different options in my application :)
SvcSecurity.SecurityClient security = new SecurityClient(ENDPOINT_PROJ_SECURITY);
string adminGroupsString = ConfigurationManager.AppSettings["adminGroups"];
string readWriteString = ConfigurationManager.AppSettings["readWriteGroups"];
string readOnlyString = ConfigurationManager.AppSettings["readOnlyGroups"];
List<string> adminGroups = new List<string>(adminGroupsString.Split(';'));
List<string> readWriteGroups = new List<string>(readWriteString.Split(';'));
List<string> readOnlyGroups = new List<string>(readOnlyString.Split(';'));
List<Guid> adminGroupIDs = new List<Guid>();
List<Guid> readWriteGroupIDs = new List<Guid>();
List<Guid> readOnlyGroupIDs = new List<Guid>();
List<Project> projectList = new List<Project>();
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["RDB"].ConnectionString);
con.Open();
SqlCommand command = new SqlCommand("SELECT * FROM MSP_EpmResource where ResourceNTAccount = @username", con);
command.Parameters.AddWithValue("@username", this.User.Identity.Name);
SqlDataReader reader = command.ExecuteReader();
if (reader.Read())
string resourceID = reader["ResourceUID"].ToString();
//Get a list of security groups
SvcSecurity.SecurityGroupsDataSet sgds = security.ReadGroupList();
//Get the IDs of the required groups
foreach (SvcSecurity.SecurityGroupsDataSet.SecurityGroupsRow ds in sgds.SecurityGroups)
if (adminGroups.Exists(group => ds.WSEC_GRP_NAME == group))
adminGroupIDs.Add(ds.WSEC_GRP_UID);
else if (readWriteGroups.Exists(group => ds.WSEC_GRP_NAME == group))
readWriteGroupIDs.Add(ds.WSEC_GRP_UID);
else if (readOnlyGroups.Exists(group => ds.WSEC_GRP_NAME == group))
readOnlyGroupIDs.Add(ds.WSEC_GRP_UID);
bool isAdmin = false;
//Go through each group using the id and check if the current
//user is in that group (for example here check if the user is an admin)
foreach (Guid id in adminGroupIDs)
SecurityGroupsDataSet group = security.ReadGroup(id);
foreach (SvcSecurity.SecurityGroupsDataSet.GroupMembersRow member in group.GroupMembers)
if (member.RES_UID.ToString().Equals(resourceID))
isAdmin = true;
Session["createReport"] = "true";
break;
//If the user is not an admin then continue checking who they are
if (!isAdmin)
bool readWrite = false;
//Check if the user is a read write group member
foreach (Guid id in readWriteGroupIDs)
SecurityGroupsDataSet group = security.ReadGroup(id);
foreach (SvcSecurity.SecurityGroupsDataSet.GroupMembersRow member in group.GroupMembers)
if (member.RES_UID.ToString().Equals(resourceID))
Session["createReport"] = "true";
readWrite = true;
break;
//If the user is not a read write group member either then check if they are a team member
if (!readWrite)
foreach (Guid id in readOnlyGroupIDs)
SecurityGroupsDataSet group = security.ReadGroup(id);
foreach (SvcSecurity.SecurityGroupsDataSet.GroupMembersRow member in group.GroupMembers)
if (member.RES_UID.ToString().Equals(resourceID))
Session["createReport"] = "false";
break;
Cheers! :)

Similar Messages

  • Preventing the logged in user from accessing the site

    Hi,
    wanted to know if it is possible that a user who has already logged in can be prevented from logging in if the user opens a new browser window (IE or Netscape)...on the same machine as well as from different machine.
    If there r any programs or guidelines available on this...please let me know.
    thanks in advance
    rinkub

    If the user tries to log in the second time on the same machine (with the same type browser) they will have the same "session" as the first time they logged in.
    So, you could check something in the session and not allow the second logon.
    In the other case, you will need to keep the users logon information some place (like a database) and check to see if they are already logged on.

  • Programatically Check if the logged in user matches with user in a list item

    Hi All, 
    I have a custom list with 1) title column 2) People column. 
    I simple need to check if the logged in user = user in the column 2, and if yes fill a List<> with column 1 value. 
    But when comparing, the value in list item is in different format than what we get by user.ToString() 
    Following is what I tried: 
    SPUser user = oWeb.CurrentUser;
    List<String> usergrps = new List<String>();
    foreach (SPListItem itemA in GrpSubsItems)
    if (itemA["SubscribedBy"].ToString() == user.ToString())
    usergrps.Add(itemA["Group"].ToString());
    itemA["SubscribedBy"].ToString() gives = 10;#Some Name
    where as user.ToString() gives = i:0#.w|domain\user 
    Kindly guide if my approach is not correct. Thanks. 
    Regards, Nayan

    Hi Nayan,
    Please modify the code like below:
    SPUser user = oWeb.CurrentUser;
    List<string> usergrps = new List<string>();
    foreach (SPListItem itemA in GrpSubsItems)
    string userName = itemA["SubscribedBy"] as string;
    SPFieldUserValue userA = new SPFieldUserValue(itemA.ParentList.ParentWeb, userName);
    if (userA.LoginName==user.LoginName)
    usergrps.Add(itemA["Group"].ToString());
    More information:
    http://ethan-deng.blogspot.com/2013/03/get-spuser-from-user-column-there-are.html
    Best Regards,
    Dennis Guo
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • An unexpected error occurred processing your request. Check the logs for details and correct the problem.

    Hi All,
    I am configuring RSS Viewer webpart to SP 2013. 
    But i am getting an error "An unexpected error occurred processing your request. Check the logs for details and correct the problem."
    I looked for solution of this error. i got to know, we need to set proxy server in web.config file.
    So, in order to resolve this i put the following set of code in web.config and save the file
    <system.net>
        <defaultProxy>
          <proxy usesystemdefault="True" proxyaddress="http://myproxyserver" bypassonlocal="True" />      
        </defaultProxy>
      </system.net>
    But, still i am getting the error. 
    What could be the problem now. 
    Any help is much appreciated. 
    Thanks,
    Rakesh

    Hi Rakesh,
    According to your description, my understanding is that you got an error when you used RSS viewer web part in SharePoint 2013.
    The RSS viewer web part uses authentication delegation and is using the current user's credentials to access the proxy. However, the RSS viewer only supports anonymous and Kerberos authentication. So if you are using NTLM authentication, the RSS viewer will
    not be able to authenticate the user through the proxy. More information, please refer to the link:
    http://kalsing.blogspot.com/2007/11/troubleshooting-rss-viewer-web-part.html
    Also see:
    http://blogs.technet.com/b/sharepointdse/archive/2007/04/13/fun-with-rss.aspx
    I hope this helps.
    Thanks,
    Wendy
    Wendy Li
    TechNet Community Support

  • Remote control kicks you out when trying to change the logged in user by clicking on the red N

    I'm running Zen 6.5 with the latest updates and the latest agents... I can
    successfully remote control a workstation through ConsoleOne but I have 2
    issues:
    1. If I'm in the middle of a remote session and I right click on the red
    N icon and change the user, it kicks me out and says "operation is
    currently disabled for the logged in user".
    2. Whenever I log in it changes the desktop background to blank (it's
    actually a blue background) and it doesn't change it back after I close
    the remote session. If I physically go that workstation and logout and
    log back in, it still keeps that same blue background.

    Gilbert,
    It appears that in the past few days you have not received a response to your
    posting. That concerns us, and has triggered this automated reply.
    Has your problem been resolved? If not, you might try one of the following options:
    - Do a search of our knowledgebase at http://support.novell.com/search/kb_index.jsp
    - Check all of the other support tools and options available at
    http://support.novell.com.
    - You could also try posting your message again. Make sure it is posted in the
    correct newsgroup. (http://support.novell.com/forums)
    Be sure to read the forum FAQ about what to expect in the way of responses:
    http://support.novell.com/forums/faq_general.html
    If this is a reply to a duplicate posting, please ignore and accept our apologies
    and rest assured we will issue a stern reprimand to our posting bot.
    Good luck!
    Your Novell Product Support Forums Team
    http://support.novell.com/forums/

  • The logged in user does not have permissions to perform this operation

    OIM 11.1.2.0.4
    Connector: Microsoft Active Directory User Management 11.1.1.5.0
    Action: revoke a provisioned AD account (logged in user is XELSYSADM member of SYSTEM ADMINISTRATIONS role)
    Error message: IAM-2050243 : Orchestration process with id 5756, failed with error message IAM-4065011 : An error occurred in oracle.iam.provisioning.spi.DOBProvisioningMechanism/revoke(Account) while revoking account with id 1 for the user with key 43 and the cause of error is The logged in user does not have permissions to perform this operation..

    The problem is missing entries into table AAD, Provisioning API uses table AAD to check administrator's scope on the user's organization.
    TEST: following SQL statement should return at least a value
    select aad_write, aad_delete
    from aad aad
    , usr usr
    where aad.act_key = usr.act_key
    and usr.usr_key = <user_key_of_user_you_wanto_to_revoke>
    and aad.ugp_key in (
    select ugp.ugp_key
    from ugp ugp
    , usg usg
    where ugp.ugp_key = usg.ugp_key
    and usg.usr_key = <user_key_of_xelsysadm>
    BUG (in my case): if you create an Organization using a OIM user that does not have any Role (except default ALL USERS Role) the system does NOT add right entries into AAD table, so you can revoke account of users that are members of this Organization
    WORKAROUND: manually insert entries for all Organizations (ACT_KEYs) for the user XELSYSADM into AAD table
    FIX: always create an Organization using a OIM users with at least one Role except ALL USERS role

  • How to determine the logged in user - BI Publisher

    Hi,
    I am building a SQL based BI Publisher report. I am using BI Publisher integrated with the E-Business Suite so all ebiz users can log in to BI Publisher
    I have a requirement that my parameter LOV query is to be restricted based on the BI publisher logged in user. I have the necessary select statement which just requires the logged in user to be supplied. But I don't know if there is any standard BI variables which I can use in my SQL Query
    Thanks
    Shasik
    Edited by: Shasik on Sep 14, 2008 1:04 AM

    Hi Shashi,
    http://winrichman.blogspot.com/2008/09/how-to-get-logged-in-obiee.html
    Use the available XDO session variables like :xdo_user_name
    Select :xdo_user_name from dual wil fetch you , the Logged in USER :)

  • 'The logged-on user does not have permission to use this object'

    Hello everyone,
    I am getting the message 'The logged-on user does not have permission to use this object' while saving the Sales Order. I am logging in as a CRM user. There is an addon also running on the server, that saves some data into a user defined table when the Sales Order is saved. Is there any authoisation for users to access user defined tables.
    Regards,
    William

    hi William,
    this is an Authorization issue. provide the user with authorization on your UDT. Definition of user authorization can be found in Administration -- >> System Initialization -->> Authorizations -->> Additional Authorization Creator.... if already defined from here you can fined the additional authorization from the General authorization window.
    regards,
    Fidel

  • Dashboard based on Crystal Report's Latest instances for the logged in user

    Hi,
    I am trying design a dashboard based on LiveOffice-crystal report's latest instance for the logged in user. Also there is row level security in the universe on which the crystal reports is created.
    In the live office connection i have selected 'latest instance by current user' in the refresh option and published the dashboard to InfoView.
    when i open the dashboard in InfoView , i find the row level restrictions being applied for different users. But the data retrived is always on-demand data and not based on the latest instance of the logged in users.
    Can anyone throw some light on this issue.
    Thanks

    Hi,
    I am trying design a dashboard based on LiveOffice-crystal report's latest instance for the logged in user. Also there is row level security in the universe on which the crystal reports is created.
    In the live office connection i have selected 'latest instance by current user' in the refresh option and published the dashboard to InfoView.
    when i open the dashboard in InfoView , i find the row level restrictions being applied for different users. But the data retrived is always on-demand data and not based on the latest instance of the logged in users.
    Can anyone throw some light on this issue.
    Thanks

  • How can I know the security role of the logged in user

    When you design an enterprise bean or Web component, you should always think about the kinds of users who will access the component. For example, an Account enterprise bean might be accessed by customers, bank tellers, and branch managers. Each of these user categories is called a security role, an abstract logical grouping of users that is defined by the person who assembles the application. When an application is deployed, the deployer will map the roles to security identities in the operational environment.
    But wondering when I log into my application with some user name and password (specified in my Oracle database),wondering how this works with the security role I created .How does J2EE know the security role of the logged in user.
    Thanks
    Manohar

    shet wrote:
    role at run time.
    When I login say as "manju" and password as "money" then how does it know that this user belongs to this security role.Is that the j2ee administrator has to say that user manju has this this security role.Programmitically how does it really work.I am confusedThe j2ee implementation assigns the roles using the JAAS module you have configured for your application on your application server. different JAAS modules get roles in different ways. many allow a single static role to be assigned using a config file. if using a database, often there will be configuration to specify additional database fields which specify the role for a given username.
    At runtime, a developer can test roles using methods like EJBContext.isCallerInRole().

  • How to get the Capability of the Logged In User

    Hi All,
    I am trying to get the Capabilities of the logged in user, but iam only getting the capabilities of the "Configurator" irrespective of who has logged in.
    I am using the following code.
    <Field name='Capability'>
    <Display class='Label'/>
    <Default>
    <invoke name='getCapabilities' class='com.waveset.ui.FormUtil'>
    <ref>:display.session</ref>
    </invoke>
    </Default>
    </Field>
    Iam using Sun IDM 5.0 with Service Pack 4. Before service pack was installed i was getting the correct result. Now iam not getting the result after the service pack is installed.
    What might be the issue ?
    Can anyone guide me on this.
    Thanks in Advance.
    Regards,
    Siva

    hi danareed
    Could you post the code to do that?, I'm trying to get the capabilitites for Any given user from the WSObject getting the AdminGroups, but I'm unable to get the capabilities from this object, what I get is an array of AdminGroup objects, how I can get the capabilities from here?
    <get>
    <invoke name='getObjectIfExists'>
              <select>
                <ref>context</ref>
                <ref>given_context</ref>
                <ref>:display.session</ref>
                <invoke name='getLighthouseContext'>
                  <ref>WF_CONTEXT</ref>
                </invoke>
              </select>
              <s>User</s>
    <s>myUser</s>
    </invoke>
    <s>AdminGroups</s>
    </get>thanks
    Edgar Torres

  • How to get the currency of the logged in user using an el expression

    I want to get the currency of the logged in user using an el expression. I can get the same using ApplSessionUtil.getCurrency(). But can i get the same using an el exprssion?. I want to use this el expression for setting the default value of a VO attriubte
    Thanks in advance

    Hi
    If you are getting the currency value from ApplSessionUtil.getCurrency() set the result of the value to one of your VO on Bean and use it in your el expression .
    Thanks
    Raghav

  • How to see the logged in user on the portal EP6 SP2

    Hi All,
    I am using EP6.0 SP2 Patch 5.I want to know that which users are logged on.Can I see the user id of the logged in user inthe portal.
    Any suggestions.
    Paritosh

    Hi Paritosh,
    I think SAP Note 762004 should answer your question!
    Best regards,
    Robert

  • How to fetch the logged in user?

    Hi Friends,
    In my BSP application, I need to capture some data from the logged in user. For this I need to fetch the logged in user name, through my BSP application.
    Could you please let me know, whether there is any FM or API, which serve the purpose for me.
    Your help in this regard is highly appreciated.
    Thanks & Regards,
    John

    Hi,
    Use the system variable  SY-UNAME .
    Regards,
    Anubhav.

  • Reflecting the value of the logged in user in an af:inputText Column

    Hi
    I have a Af:table with multiple Rows. In one of my Af:columns I want to reflect the logged in user and store this value when I commit the page.
    I am using JAZN security. Please Help.

    Please follow the guidelines available at the top of this forum when posting. As such give us more details about what version of JDeveloper you're using, and which technologies including the model layer like ADF BC you're using.
    If you're using ADF BC, at the EO attribute level there are history properties for defaulting an attribute's value to that of the JAZN user. This is an ideal location to set this if you're using ADF BC. But as you haven't included any information about what model layer technology you're using it is hard to help you further.
    CM.

Maybe you are looking for

  • How to create Event Node in smartform

    Hi Experts, could you please tell me how to create event node in smartform Thanks in Advance, Thanks&Regards Geetha

  • ERROR WHILE STARTING SERVICE AT ENTERPRISE MANAGEMENT IN OBIEE11G

    Hi, I am facing error while uploading RPD in to Enterprise Management. When starting Services iam able to start all except "BISERVICES". It is showing 80% success and 20% failed. By seeing the error iam able to find it is problem with server. Can any

  • CS4 keeps crashing on my new MAC 10.7.4

    Can someone help me. It was working fine on my last computer but since reinstalling CS4 it just keeps crashing every time I want to delete a page, generate a pdf or do a relink on some images. I use this software all the time for work and am having h

  • Problem setting up the UCP Web Service

    I am new to CISCO and my first project is to set up the UCP Web Service.  I don't have access to the web interface on ACS but I was told that acs config-web-interface ucp enable was run.  I have in the UCP file on tomcat C:\Tomcat 7.0\webapps\ROOT\UC

  • Outlook 2003 Calendars do not appear in iTunes 7.3

    Sorry to rehash this issue... If I connect my iPhone to my PC and look at the info tab for the Calendars section iTunes says Sync calendars from Outlook (the only choice in the drop-down), but it is defaulted to All Calendars (Selected Calendars is g