ADO. NET Data Service access permission settings
Download: http://files.cnblogs.com/wxwinter/power.rar
In An ADO. NET Data Service
Http://www.cnblogs.com/foundation/archive/2008/11/18/1335583.html
Many of my friends asked me how to set the permissions for the ADO. NET Data Service. In fact, the permission for setting the ADO. NET Data Service is the same as that for setting the resource access permission for the ASPNET website normally.
The following example is a prototype of ADO. NET Data Service. It describes how to set resource access permissions.
First, plan the resource structure of the ASPNET website.
Configure permissions in Web. config according to the above design
|
<Authentication
Mode = "Forms">
<Forms
Name = "poweridtag"
LoginUrl = "publicweb/login. aspx"/>
</Authentication>
<Authorization>
<Deny
Users = "? ">
</Deny>
</Authorization> |
|
<Location
Path = "ClientBin">
<System. web>
<Authorization>
<Allow
Users = "*">
</Allow>
</Authorization>
</System. web>
</Location>
<Location
Path = "publicweb">
<System. web>
<Authorization>
<Allow
Users = "*">
</Allow>
</Authorization>
</System. web>
</Location> |
Add a loginService. svc service to publicweb to provide Logon
|
[ServiceContract (Namespace = "")]
[AspNetCompatibilityRequirements (RequirementsMode = AspNetCompatibilityRequirementsMode. Allowed)]
Public
Class
LoginService
{
[OperationContract]
Public
String login (string userID, string password)
{
// Determine the userID and password
System. Web. Security. FormsAuthentication. SetAuthCookie ("dbadmin", false );
Return
"OK ";
}
} |
Add a reference to the loginService. svc service in SilverlightApplication and log on as follows:
|
Private
Void login_Click (object sender, RoutedEventArgs e)
{
LoginServer. loginServiceClient lsr = new SilverlightApplication. loginServer. loginServiceClient ();
Lsr. loginCompleted + = new
EventHandler <SilverlightApplication. loginServer. loginCompletedEventArgs> (lsr_loginCompleted );
Lsr. loginAsync (this. userID. Text, this. password. Text );
}
Void lsr_loginCompleted (object sender, SilverlightApplication. loginServer. loginCompletedEventArgs e)
{
If (e. Result = "OK ")
{
MessageBox. Show ("Logon successful ");
}
} |
Check the effect