ADO. NET Data Service access permission settings

Source: Internet
Author: User
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

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.