function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ronshayronshay 

Getting user information

I have an application using the sforce web services.  When I request a login and password for salesforce, is there a way I can tell if the person is an administrator or whatever?  Thanks.

darozdaroz
A quick look shows that you can take the userId returned from login and retrieve the ProfileId from the User table. From there lookup that ProfileId (as Profile.Id) and you will get a list of colums and permissions that user has.
ronshayronshay
Thanks, but being new to this web service and only have the user manual, I'm still not clear on this.
darozdaroz

First, especially if you're new to the API I'd strongly recommend playing around with the sForce Explorer... (http://prdownloads.sourceforge.net/sforce/csPatnerSample_with_source.zip?download)

First, the API Login() call will return a LoginResult object. One of that objects members is the userID member. That is a 15 (or 18 - I don't recall right now) character string.

Second, Query() the User object to get the ProfileId for that user using SOQL something like this: "Select ProfileId from User Where Id = '(userID from LoginResult Here)'"

Lastly, you need to get the information from the Profile Object... You can Query() for this using SOQL like this:

Select CreatedById, CreatedDate, Id, LastModifiedById, LastModifiedDate, Name, PermissionsApiUserOnly, PermissionsCreateAccount, PermissionsCreateSolution, PermissionsCustomizeApplication, PermissionsDeleteAccounts, PermissionsDeleteOpportunity, PermissionsEditAccount, PermissionsEditCase, PermissionsEditContact, PermissionsEditContract, PermissionsEditDocument, PermissionsEditEvent, PermissionsEditForecast, PermissionsEditLead, PermissionsEditOpportunity, PermissionsEditOwnQuota, PermissionsEditPricebook, PermissionsEditProduct, PermissionsEditPublicDocuments, PermissionsEditReadonlyFields, PermissionsEditTask, PermissionsImportLeads, PermissionsManageCases, PermissionsManageCssUsers, PermissionsManageDashboards, PermissionsManageLeads, PermissionsManagePrivateSolutions, PermissionsManageSelfService, PermissionsManageSolutions, PermissionsManageUsers, PermissionsModifyAllData, PermissionsOverrideForecasts, PermissionsRunReports, PermissionsSendSitRequests, PermissionsTransferAnyEntity, PermissionsTransferAnyLead, PermissionsViewAllData, PermissionsViewAllForecasts, PermissionsViewSetup, SystemModstamp from Profile Where Id = '(ProfileID from User Object Here)'

I think this will take care of what you need. But definately play with the sForce explorer -- well worth it to 'see' what the API will return for you.

ronshayronshay
Thanks for you help.  I'lll give it a try.
ronshayronshay

Two other things, the explorer is great, do you know if there is a vb.net example anywhere?  Finally, what I'm trying to find out is that whoever logs on, if they are a system administrator, etc.  Is that a user role?

 

Thanks again for your help.

ScotScot

You will need to determine what your definition of "administrator" should be; this definition is not hard and fast, but is dependent on the on the user profile (not role). This is what you see when you to to Setup / Manage Users / Profiles in the sf html pages.

There is a default profile, System Administrator, which gives access to every capability in the system: a list of about 50 different permissions.  However, you can configure salesforce to add a custom profile, perhaps named "Fred" which might include all the same permissions ... or, say, 48 of the 50.

To check the user permissions, you need to retrieve the user profile (as explained in the great comment by daroz earlier). If all you care about is the default System Administrator, you can test for the name equal to "System Administrator". More likely, you'll want to define an administrator - based one or more of the permissions that the user is granted. Many of those permissions are included in the fields retrieved in the example.

ronshayronshay

Thanks Scot.  The link sent to me by Daros was great.  Unfortunatley the sample is in C#.  I'm a VB.net developer so I guess I'll have to muddle through the C# code.  Too bad there isn't a good vb.net example.

 

Thanks for the response