C# - Want To Create A Custom Roleprovider Through A WCF Service?
May 17, 2010
I have a web application that accesses a database through a wcf service. The idea is to abstract the data from the web application using the wcf service. All that works fine but I am also using the built in roleprovider using the SqlRoleManager which does access the aspnetdb database directly. I would like to abstract the roleprovider by creating a custom roleprovider in a wcf service and then accessing it through the wcf service.
I have created the custom role provider and it works fine but now I need to place it in a wcf service. So before I jump headlong into trying to get this to work through the WCF service, I created a second class in the web application that accessed the roleprovider class and changed my web config roleprovider parameters to use that class. So my roleprovider class is called, "UcfCstRoleProvider" and my web.config looks like this:
<roleManager
enabled="true"
defaultProvider="UcfCstRoleProvider">[code]....
But I get this error."Provider must implement the class 'System.Web.Security.RoleProvider'."
I hope I have explained well enough to show what I am trying to do. If I can get the roleprovider to work through another class in the same application, I am sure it will work through the WCF service but how do I get past this error?Or maybe I took a wrong turn and there is a better way to do what I want to do??
View 3 Replies
Similar Messages:
May 18, 2010
I have created a custom MembershipProvider and RoleProvider which communications with some existing business logic. The issue I have is that the user login in my business logic requires 3 arguments (group id, user id, and password) and the MembershipProvider and RoleProvider I implemented just use 1 or 2 arguments (username, password). Right now I append my group id and user id together and pass it as the username then parse it in the implemented methods. Is there a better way to do this?
Note, I can handle the login fine because I can call my own ValidateUser method. The main issue is when the implemented methods are called from other things like the RoleProvider.GetRolesForUser(username) method when I use the AuthorizeAttribute.
[Code]....
[Code]....
View 1 Replies
May 10, 2010
I'm trying to use this article to learn about custom roleproviders, but I'm getting this error:
Could not load type 'TestRoles.SimpleRoleProvider'.
The relevant section from my web.config:
<roleManager enabled="true" defaultProvider="SimpleRoleProvider">
<providers>
<add name="SimpleRoleProvider" type="TestRoles.SimpleRoleProvider"/>
</providers>
</roleManager>
The RolesProvider.cs class:
public class TestRoles{
public class SimpleRoleProvider : RoleProvider
{
public override string[] GetRolesForUser(string username)
{
List<string> roles = new List<string>();
roles.Add("Guest");
if (username.Equals("Dave"))
roles.Add("Admin");
return roles.ToArray();
}
}
}
From this error, it seems like it can't find the RoleProvider.
View 1 Replies
Feb 24, 2010
I am obviously missing something here and it is driving me batty. I am trying to implement a custom role provider so that I can add some of my own custom code to it. I have created my CustomRoleProvider class, I have inherited the RoleProvider base class and implemented its members. I have made the required changes to my web.config so that my CustomRoleProvider is used. This is all working great.
All of this is wrapped up in a wrapper class as provided by the MVC Membership Starter Kit that I am using and wish to extend.
Now I want to add my own custom functionality.
When I add a function to my CustomRoleProvider I cannot see it or access it.
How do I add functionality to my CustomRoleProvider so that I can use it?
View 1 Replies
Apr 4, 2011
I have created custom membership and role providers for a SharePoint web application.
If I deploy the DLL for these classes into the GAC, the membership/role provision works just fine. If I deploy these DLLs to the web application's bin folder in IIS, the web app bails with a server error immediately when browsing to the site.
Parser Error Message: Exception has been thrown by the target of an invocation.
If I view source on the error page I get a bit more info:
[code]....
View 1 Replies
Feb 20, 2010
I'm making a custom MembershipProvider and RoleProvider.
I have database tables with Roles and UsersInRoles and I use LINQ-to-SQL to create objects of the tables.
When invoking [Authorize] on an action method, will it work with my custom RoleProvider?
How does it know if the user is authenticated and if the user is in the appropriate role?
View 1 Replies
Oct 15, 2010
I have written an assembly (DLL) containing two classes, MyMembershipProvider and MyRoleProvider, which are derived from MembershipProvider and RoleProvider, respectively. I have implemented most but not all of the abstract methods; the remaining ones all throw a NotImplementedException. I have signed the assembly and added a reference to it in my web-site project, where the relevant web.config sections look like this:
[Code]....
When I fire up the site, however, I get the following error:
Configuration Error
Description:
An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message:
Exception has been thrown by the target of an invocation.
The error message points to the <add /> tag in the <roleManager /> section: if I take that out, however (enabled="false"), it comes back again as soon as I try to log-in to the site (this time pointing to the membership section). I have verified that is recognising the classes by changing the name in the "type" attribute (to something that doesn't exist), at which point it throws a different error. Therefore I'm presuming there's a problem with my assembly code somewhere; but how can I find out where? I have debug=true in the web.config and also compiled the assembly with Debug options, but no clues.
View 4 Replies
Jun 18, 2010
I had a post here [URL] that I need to expand on now. I have a few web pages that need to check for a certain role on each page request. I have a custom Membership Provider and a custom Role Provider (called CustomRoleProvider - very original - I know) that I am using to do this. When a user logs in, the CustomRoleProvider.GetRolesForUser() method is called automatically (by the urlAuthorizationModule). When this method gets called, I am currently adding a role to the roles string array that allows/permits the user from viewing the web pages of concern based on certain qualifications that are determined elsewhere in the code (i.e. the database is queried to see if the user has rights to visit certain pages).
This approach only gets me half way because the user's roles are only checked once at login. When I wrote my previous post, I thought the CustomRoleProvider was broken because it wasn't calling the IsUserInRole() method on each page request. According to Microsoft, "The IsUserInRole method is called by the IsUserInRole method of the Roles class to determine whether the current logged-on user is associated with a role from the data source for the configured ApplicationName." (that information comes from this page:
[URL] Reading that description I thought it was being called automatically on each page request. This is not correct. What I need to know how to do is to get a method in the CustomRoleProvider that returns a boolean to be called automatically on each page request so I can update the user's roles if they change while the user is logged into the web site. For example, if the user has rights to visit page A and then five minutes later his rights are revoked, he can't visit page A again unless he contacts an admin to reset his rights.
View 1 Replies
May 24, 2012
I developed a web service in VS2010 on my local machine, wrote a consumer of it also locally, and that all works.
I copied the dll and the asmx file to our server, and I am getting an error when I try to invoke it from a browser (also still on the server machine) to make sure it correctly exposes its web methods, but it is not, it is saying "Could not create type 'Service'". That error comes from this line:
Line 1: <%@ WebService Language="C#" CodeBehind="~/App_Code/WarrantyDuplicate.cs" Class="Service" %>
There other web services in the same folder on the server that all work fine so I don't believe it's an IIS setup thing.
This is my first web service in C# and when I created it in VS I did think it odd that the code behind file went into App_Code (as you can see from the line in the asmx file) and is just named dot-cs rather than asmx-dot-cs. But since it worked fine locally, I wasn't sure that mattered.
View 2 Replies
Mar 17, 2011
How to create an instance of web service without adding web service reference? How to identify the server address/name where the web service is hosted from C# code?
View 1 Replies
Aug 30, 2010
How to create simple web service in VS2010 Professional (trial version). There is no template to do this. I am not trying to create WCF service here.
View 2 Replies
Oct 22, 2010
I want to create a custom control where I define several specifically named DIV sections. The code-behind logic of the custom control will perform operations on these named DIV sections. The page where the custom control is hosted needs to be able to add named controls to the DIV sections and perform operations on these named controls added to the DIV sections.
Let me explain a little further. In the custom control, I want to have code behind logic that fires the following Page Event and uses a condition to make one or another specifically named DIV section visible or not:
< _
ToolboxData("<{0}:BaseDetails runat=""server""></{0}:BaseDetails>") _
> _
Public Class BaseDetails
[code]...
how can I create a custom control which is able to generate the named DIV sections "DetailsNameDiv1" and "DetailsNameDiv2" where my custom control can check a condition and make one or the other visible. Also, I need to be able to add controls to these named DIV sections when I host the custom control and the control that I add to the named DIV section needs to let me set values of these controls from the code behind logic of the page (or usercontrol) where the custom control is being hosted (in my example, I am adding TextBox controls that I want to set the Text property from a SQL Data Reader).
View 3 Replies
Feb 24, 2011
I have currently on multiple pages a modal popup that displays the information below, we are getting to the point where we need to call this popup from multiple locations, currently i have duplicate setups on each page that i want to use it on, but its becoming a mess to manage when a change is needed.. so im looking to see if what i have within the modal popup can be turned into a control that i can call anywhere thru out the site and have just 1 setup to maintain going forward..If its possible to create a control that can then be placed within the modal popup and server the same purpose that would be great any links here is what i have within the modal popup that i have on atleast 3 pages currently..
[Code]....
View 2 Replies
Dec 19, 2010
I want to create a custom web part in SharePoint 2007 that allows me to take items from an existing custom list (i.e. Title, Hyperlink, Description and photo) and then render it in a format of my choice. How can I do this using C# asp.net and a web part?
View 1 Replies
May 15, 2010
I know that how to create custom control and add custom property.
I want to create property like DataSource to my custom control.
View 1 Replies
Oct 26, 2010
I want to create a custom Toolbox in asp.net which will contain all custom control that i have made. Now the user will drag these controls from custom toolbox at run time and create form. I tried but did not succeeded.
View 1 Replies
Feb 15, 2010
I am trying to create a web custom control but I am unable to find the templete that should be in my projects window. I am using Visual Studio Pro and it should be there. Doc's say standard version doesn't have it but thats all I can find.
View 4 Replies
Jan 20, 2011
i want to create a web service which consists of CRUD operations Create, Retrieve, Update and Delete. creating web methods on insert and update operations.
View 2 Replies
Jun 3, 2010
The GetRolesForUser() method in the RoleProvider takes the user login name and returns the list of roles for that user. But in my application this is not enough, I need a few more pieces of information to be able to get the user's roles. How can I get this extra information into the method? I have it in the Session, but I found out that Session is not available in the RoleProvider.
What I had in mind was putting this extra info in some class that extends MembershipUser, assuming I can get to it inside the RoleProvider. But I don't know how to create the CustomMembershipUser and make it part of the MembershipProvider. Is this even possible? The easy way out would be using cookies, but I'm trying to keep away from it.
View 1 Replies
Nov 16, 2010
I trying to understand how a server farm would use MembershipProvider / RoleProvider. If I have a million users, I do not want to have multiple copies of the MembershipProvider / RoleProvider database. I would like to have one set of machines used for login but then redirect users to other machines in the server farm depending applications the users decide to use. However, once they are redirected to the new machine, I do not want the user to have to relogin. I want the credentials and role information to be available.
Does anyone know how MembershipProvider / RoleProvider is configured for this type architecture?
View 4 Replies
Feb 11, 2011
I'm trying to implement the following adjustments to the default ASP.NET RoleProvider so that it supports hierarchical role definitions. However i cannot create the following function, it keeps Executing the function.
Ref: [URL]
What is wrong with this function?
-- Template generated from Template Explorer using:
-- Create Multi-Statement Function (New Menu).SQL
--
-- Use the Specify Values for Template Parameters
-- command (Ctrl-Shift-M) to fill in the parameter
-- values below.
--
-- This block of comments will not be included in
-- the definition of the function.
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
CREATE FUNCTION [dbo].[aspnet_Roles_Ancestor_TVF] (
@RoleId uniqueidentifier
)
RETURNS
@aspnet_Roles TABLE (
ApplicationId uniqueidentifier
, RoleId uniqueidentifier
, RoleName nvarchar(256)
, LoweredRoleName nvarchar(256)
, Description nvarchar(256)
, ParentRoleId uniqueidentifier
)
AS
BEGIN
; WITH aspnet_Roles_CTE (
ApplicationId
, RoleId
, RoleName
, LoweredRoleName
, Description
, ParentRoleId
, HierarchyLevel
) AS (
[Code.....]
View 2 Replies
Dec 25, 2010
Does Forms Authentication require that cookies be enabled to use MembershipProvider and RoleProvider? If so, can anyone tell me the minimum security level I need to tel clients to use.
View 2 Replies
Aug 31, 2010
Say for my ASP.NET application, I have implemented my custom RoleProvider by using my existing Users table on my Oracle 11g database. Then, for my Membership Provider, can I still use the AspNetSqlMembershipProvider that comes with the .NET framework and uses SQL Server?
View 4 Replies
Aug 11, 2010
I have created a WCF service that will serve as authentication service for Silverlight client.The problem is that when I make a call to FormsAuthentication.SetAuthCookie in the Login method below, I get a null reference exception. I am following the 'Securing Applications Built on Silverlight and WCF' (http://www.componentart.com/community/blogs/milos/archive/2009/05/07/securing-applications-built-on-silverlight-and-wcf.aspx)
[Code]....
View 1 Replies
Feb 11, 2010
I'm kinda new to web services and want to make sure I am doing things correctly.
I have a custom object which has sub objects as well. (let's say Company object, sub object is collection of Employee objects)
I want the web service to return a collection of Company objects. Do I make the service return a Dataset and custom generate a dataset with datatables representing the different objects?
What is the best way to do this? I tried to just serialize it, but that doesn't seem to work either.
I tried this dll
[URL]
But the output XML doesn't seem to include the sub object.
View 1 Replies