Click here to Skip to main content
15,903,854 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello All,

We are giving a c# webservice which contains 10 webmethods which will return different data to clients...

I want to restrict the access of web methods to different clients with diffrent set of methods....


For example I have written webmethods named A,B,C,D,E,F,G,H,I,J


Client A - B,D,F,G
Clent B - A,B,C,D,E,F,G,I
Client C - A,B,C,D,E,F,G,H,I,J

In current scenario, We are having more than 200 clients and more than 500 web methods....

How can i do this???

Can I use database driven mechanism to achieve this? If possible how?

I have already used SOAPHEADER to authenticate all users.... I have a SQL table like client master which will give the IP address for the requesting client to authenticate the request....


Thanks in advance...
Posted
Updated 19-Apr-10 19:51pm
v3

You've just about answered your own question here...

You already have user authentication happening, so simply update your database so that you have a table similar to this:

UserID, WebMethodID

Populate this table with relevant details for each client and their approved webmethods, one entry per client/webmethod pair.

Update your webmethods so that they only work if the client/webmethod pair is authorised... something like this:

VB
if isAuthorised(ClientID, WebmethodID) then

' do the webmethod stuff here

endif

private function isAuthorised(byval ClientID as integer, byval WebmethodID as integer) as boolean
' Make a call to the database to check for the ClientID/Webmethod pair

if FOUND_IN_DATABASE then
  isAuthorised = true
else
  isAuthorised = false
endif
end function
 
Share this answer
 
v2
You can always put some logic to find the client and based on the client sent back the response. Might be an IP range for client A, another for B ... if A is requesting then allow B,D,F,G to response back. This logic can be written in service layer or Db layer where ever you like.

But i would suggest, make 3 services... 1 each for client A, B & C. Why to club them all? It would be easy for you to maintain and can also have different types of security level if needed!
 
Share this answer
 
you could add an entry method that will be called each time any of the webmethods are called :

a()
{
if(entry()){
}
else
{
return ;
}
}

b()
{
if(entry()){
}
else
{
return ;
}
}

etc

this method can look up the user access rights and determine if the user is allowed access to the webmethod or not.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900