Custom Role Provider Web Service<p align=left><font face=Arial size=2></font>I'm trying to implement a custom role provider for my application-base, referenced through a web service. I know this is possible, but I've hit a snag in the implementation of it.</p> <p align=left> </p> <p align=left>My structure goes as follows:</p> <p align=left> </p> <p align=left><a title="http://intranet/WebServices/CustomRoleProviderWebService.asmx" href="http://intranet/WebServices/CustomRoleProviderWebService.asmx">http://intranet/WebServices/CustomRoleProviderWebService.asmx</a></p> <p align=left>my CustomRoleProviderWebService has the default RoleProvider abstract classes all created and looks like this:</p> <p align=left> </p> <p align=left> </p> <p align=left> <div class=codeseg> <div class=codecontent> <div class=codesniptitle><span style="width:100%;height:42px">Code Block</span></div> <p align=left>namespace WebService</p> <p align=left>{</p> <blockquote dir=ltr style="margin-right:0px"><font size=2> <p align=left>[</font><font color="#2b91af" size=2>WebService</font><font size=2>(Namespace = </font><font color="#a31515" size=2>&quot;http://intranet/WebServices/&quot;</font><font size=2>)]</p></font> <p align=left>public class CustomRoleProviderWebService : System.Web.Services.WebService</p> <p align=left>{</p> <blockquote dir=ltr style="margin-right:0px"><font size=2> <p align=left>[</font><font color="#2b91af" size=2>WebMethod</font><font size=2>(Description = </font><font color="#a31515" size=2>&quot;AddUsersToRoles&quot;</font><font size=2>)]</p> <p align=left></font><font color="#0000ff" size=2>public</font><font size=2> </font><font color="#0000ff" size=2>void</font><font size=2> AddUsersToRoles(</font><font color="#0000ff" size=2>string</font><font size=2>[] usernames, </font><font color="#0000ff" size=2>string</font><font size=2>[] roleNames)</p> <p align=left>{</p> <blockquote dir=ltr style="margin-right:0px"> <p align=left></font><font color="#0000ff" size=2>throw</font><font size=2> </font><font color="#0000ff" size=2>new</font><font size=2> </font><font color="#2b91af" size=2>Exception</font><font size=2>(</font><font color="#a31515" size=2>&quot;The method or operation is not implemented.&quot;</font><font size=2>);</p></blockquote> <p align=left>}</p> <p align=left>// The rest of the methods are all there... just showing that I have them specified as WebMethods</p></blockquote> <p dir=ltr align=left>}</font></p></blockquote> <p align=left>}</p> <p align=left> </p></div></div> <p align=left> </p> <p></p> <p> </p> <p align=left>In my Application, I have a reference of my WebService called RoleProvider. I can view the service, invoke the methods (even if just to throw the Exception), and for all intents and purposes, it works.</p> <p align=left>My web.config is where I'm having troubles.</p><font color="#0000ff" size=2> <p align=left> <div class=codeseg> <div class=codecontent> <div class=codesniptitle><span style="width:100%">Code Block</span></div><font color="#0000ff" size=2> <p align=left>&lt;</font><font color="#a31515" size=2>roleManager</font><font color="#0000ff" size=2> </font><font color="#ff0000" size=2>enabled</font><font color="#0000ff" size=2>=</font><font size=2>&quot;</font><font color="#0000ff" size=2>true</font><font size=2>&quot;</font><font color="#0000ff" size=2> </font><font color="#ff0000" size=2>defaultProvider</font><font color="#0000ff" size=2>=</font><font size=2>&quot;</font><font color="#0000ff" size=2>CustomRoleProvider</font><font size=2>&quot;</font><font color="#0000ff" size=2>&gt;</p> <blockquote dir=ltr style="margin-right:0px"> <p align=left>&lt;</font><font color="#a31515" size=2>providers</font><font color="#0000ff" size=2>&gt;</p> <blockquote dir=ltr style="margin-right:0px"> <p align=left>&lt;</font><font color="#a31515" size=2>clear</font><font color="#0000ff" size=2>/&gt;</p></font><font color="#0000ff" size=2> <p align=left>&lt;</font><font color="#a31515" size=2>add</font><font color="#0000ff" size=2> </font><font color="#ff0000" size=2>name</font><font color="#0000ff" size=2>=</font><font size=2>&quot;</font><font color="#0000ff" size=2>CustomRoleProvider</font><font size=2>&quot;</p></font><font color="#0000ff" size=2> <blockquote dir=ltr style="margin-right:0px"> <p align=left></font><font color="#ff0000" size=2>roleProviderUri</font><font color="#0000ff" size=2>=</font><font size=2></font><font color="#0000ff" size=2><a title="http://intranet/WebServices/CustomRoleProviderWebService.asmx" href="http://intranet/WebServices/CustomRoleProviderWebService.asmx">http://intranet/WebServices/CustomRoleProviderWebService.asmx</a></font><font size=2></p></font><font color="#0000ff" size=2> <p align=left></font><font color="#ff0000" size=2>applicationName</font><font color="#0000ff" size=2>=</font><font size=2>&quot;</font><font color="#0000ff" size=2>myApplication</font><font size=2>&quot;</p></font><font color="#0000ff" size=2> <p align=left></font><font color="#ff0000" size=2>type</font><font color="#0000ff" size=2>=</font><font size=2>&quot;</font><font color="#0000ff" size=2>RoleProvider.WebService.CustomRoleProviderWebService</font><font size=2>&quot;</p></blockquote></font><font color="#0000ff" size=2> <p align=left>/&gt;</p></blockquote> <p align=left>&lt;/&lt; FONT&gt;<font color="#a31515" size=2>providers</font><font color="#0000ff" size=2>&gt;</p></blockquote> <p align=left>&lt;/&lt; FONT&gt;<font color="#a31515" size=2>roleManager</font><font color="#0000ff" size=2>&gt;</font></p> <p align=left> </p></div></div> <p align=left> </p></font> <p></p> <p align=left><font color="#0000ff" size=2></p> <p><font color="#000000">The only thing I get when I try and view a page with the roleprovider defined that way (or any way I can think of other than the right way, obviously) I get a Could not load type 'RoleProvider.WebService.CustomRoleProviderWebService' error message, which will change depending on the type I've defined. I've also tried referencing an external library by providing the classname, AssemblyName to no avail. Please ... what am I doing wrong?</font></p> <p><font color="#000000"></font> </p> <p align=left><font color="#000000">Any help is greatly appreciated!</font></font></font></font></p>© 2009 Microsoft Corporation. All rights reserved.Thu, 19 Jun 2008 00:15:52 Zb06554d9-c1c4-4b7f-840b-8087c377f7dbhttp://social.msdn.microsoft.com/Forums/en-US/asmxandxml/thread/b06554d9-c1c4-4b7f-840b-8087c377f7db#b06554d9-c1c4-4b7f-840b-8087c377f7dbhttp://social.msdn.microsoft.com/Forums/en-US/asmxandxml/thread/b06554d9-c1c4-4b7f-840b-8087c377f7db#b06554d9-c1c4-4b7f-840b-8087c377f7dbKalebhttp://social.msdn.microsoft.com/Profile/en-US/?user=KalebCustom Role Provider Web Service<p align=left><font face=Arial size=2></font>I'm trying to implement a custom role provider for my application-base, referenced through a web service. I know this is possible, but I've hit a snag in the implementation of it.</p> <p align=left> </p> <p align=left>My structure goes as follows:</p> <p align=left> </p> <p align=left><a title="http://intranet/WebServices/CustomRoleProviderWebService.asmx" href="http://intranet/WebServices/CustomRoleProviderWebService.asmx">http://intranet/WebServices/CustomRoleProviderWebService.asmx</a></p> <p align=left>my CustomRoleProviderWebService has the default RoleProvider abstract classes all created and looks like this:</p> <p align=left> </p> <p align=left> </p> <p align=left> <div class=codeseg> <div class=codecontent> <div class=codesniptitle><span style="width:100%;height:42px">Code Block</span></div> <p align=left>namespace WebService</p> <p align=left>{</p> <blockquote dir=ltr style="margin-right:0px"><font size=2> <p align=left>[</font><font color="#2b91af" size=2>WebService</font><font size=2>(Namespace = </font><font color="#a31515" size=2>&quot;http://intranet/WebServices/&quot;</font><font size=2>)]</p></font> <p align=left>public class CustomRoleProviderWebService : System.Web.Services.WebService</p> <p align=left>{</p> <blockquote dir=ltr style="margin-right:0px"><font size=2> <p align=left>[</font><font color="#2b91af" size=2>WebMethod</font><font size=2>(Description = </font><font color="#a31515" size=2>&quot;AddUsersToRoles&quot;</font><font size=2>)]</p> <p align=left></font><font color="#0000ff" size=2>public</font><font size=2> </font><font color="#0000ff" size=2>void</font><font size=2> AddUsersToRoles(</font><font color="#0000ff" size=2>string</font><font size=2>[] usernames, </font><font color="#0000ff" size=2>string</font><font size=2>[] roleNames)</p> <p align=left>{</p> <blockquote dir=ltr style="margin-right:0px"> <p align=left></font><font color="#0000ff" size=2>throw</font><font size=2> </font><font color="#0000ff" size=2>new</font><font size=2> </font><font color="#2b91af" size=2>Exception</font><font size=2>(</font><font color="#a31515" size=2>&quot;The method or operation is not implemented.&quot;</font><font size=2>);</p></blockquote> <p align=left>}</p> <p align=left>// The rest of the methods are all there... just showing that I have them specified as WebMethods</p></blockquote> <p dir=ltr align=left>}</font></p></blockquote> <p align=left>}</p> <p align=left> </p></div></div> <p align=left> </p> <p></p> <p> </p> <p align=left>In my Application, I have a reference of my WebService called RoleProvider. I can view the service, invoke the methods (even if just to throw the Exception), and for all intents and purposes, it works.</p> <p align=left>My web.config is where I'm having troubles.</p><font color="#0000ff" size=2> <p align=left> <div class=codeseg> <div class=codecontent> <div class=codesniptitle><span style="width:100%">Code Block</span></div><font color="#0000ff" size=2> <p align=left>&lt;</font><font color="#a31515" size=2>roleManager</font><font color="#0000ff" size=2> </font><font color="#ff0000" size=2>enabled</font><font color="#0000ff" size=2>=</font><font size=2>&quot;</font><font color="#0000ff" size=2>true</font><font size=2>&quot;</font><font color="#0000ff" size=2> </font><font color="#ff0000" size=2>defaultProvider</font><font color="#0000ff" size=2>=</font><font size=2>&quot;</font><font color="#0000ff" size=2>CustomRoleProvider</font><font size=2>&quot;</font><font color="#0000ff" size=2>&gt;</p> <blockquote dir=ltr style="margin-right:0px"> <p align=left>&lt;</font><font color="#a31515" size=2>providers</font><font color="#0000ff" size=2>&gt;</p> <blockquote dir=ltr style="margin-right:0px"> <p align=left>&lt;</font><font color="#a31515" size=2>clear</font><font color="#0000ff" size=2>/&gt;</p></font><font color="#0000ff" size=2> <p align=left>&lt;</font><font color="#a31515" size=2>add</font><font color="#0000ff" size=2> </font><font color="#ff0000" size=2>name</font><font color="#0000ff" size=2>=</font><font size=2>&quot;</font><font color="#0000ff" size=2>CustomRoleProvider</font><font size=2>&quot;</p></font><font color="#0000ff" size=2> <blockquote dir=ltr style="margin-right:0px"> <p align=left></font><font color="#ff0000" size=2>roleProviderUri</font><font color="#0000ff" size=2>=</font><font size=2></font><font color="#0000ff" size=2><a title="http://intranet/WebServices/CustomRoleProviderWebService.asmx" href="http://intranet/WebServices/CustomRoleProviderWebService.asmx">http://intranet/WebServices/CustomRoleProviderWebService.asmx</a></font><font size=2></p></font><font color="#0000ff" size=2> <p align=left></font><font color="#ff0000" size=2>applicationName</font><font color="#0000ff" size=2>=</font><font size=2>&quot;</font><font color="#0000ff" size=2>myApplication</font><font size=2>&quot;</p></font><font color="#0000ff" size=2> <p align=left></font><font color="#ff0000" size=2>type</font><font color="#0000ff" size=2>=</font><font size=2>&quot;</font><font color="#0000ff" size=2>RoleProvider.WebService.CustomRoleProviderWebService</font><font size=2>&quot;</p></blockquote></font><font color="#0000ff" size=2> <p align=left>/&gt;</p></blockquote> <p align=left>&lt;/&lt; FONT&gt;<font color="#a31515" size=2>providers</font><font color="#0000ff" size=2>&gt;</p></blockquote> <p align=left>&lt;/&lt; FONT&gt;<font color="#a31515" size=2>roleManager</font><font color="#0000ff" size=2>&gt;</font></p> <p align=left> </p></div></div> <p align=left> </p></font> <p></p> <p align=left><font color="#0000ff" size=2></p> <p><font color="#000000">The only thing I get when I try and view a page with the roleprovider defined that way (or any way I can think of other than the right way, obviously) I get a Could not load type 'RoleProvider.WebService.CustomRoleProviderWebService' error message, which will change depending on the type I've defined. I've also tried referencing an external library by providing the classname, AssemblyName to no avail. Please ... what am I doing wrong?</font></p> <p><font color="#000000"></font> </p> <p align=left><font color="#000000">Any help is greatly appreciated!</font></font></font></font></p>Mon, 01 Oct 2007 20:20:14 Z2007-10-15T16:37:24Zhttp://social.msdn.microsoft.com/Forums/en-US/asmxandxml/thread/b06554d9-c1c4-4b7f-840b-8087c377f7db#d1c78082-367c-427d-a197-97422c09a5c3http://social.msdn.microsoft.com/Forums/en-US/asmxandxml/thread/b06554d9-c1c4-4b7f-840b-8087c377f7db#d1c78082-367c-427d-a197-97422c09a5c3John Saundershttp://social.msdn.microsoft.com/Profile/en-US/?user=John%20SaundersCustom Role Provider Web Service<p>I presume you've seen <a title="http://www.codeproject.com/aspnet/WSSecurityProvider.asp" href="http://www.codeproject.com/aspnet/WSSecurityProvider.asp">Custom MembershipProvider and RoleProvider Implementations that use Web Services</a>? How does your code differ from what's in the article?</p> <p align=left> </p>Tue, 02 Oct 2007 00:15:48 Z2007-10-02T00:15:48Zhttp://social.msdn.microsoft.com/Forums/en-US/asmxandxml/thread/b06554d9-c1c4-4b7f-840b-8087c377f7db#6f38c2d5-f6ec-4485-8b38-08e7e3b0bb85http://social.msdn.microsoft.com/Forums/en-US/asmxandxml/thread/b06554d9-c1c4-4b7f-840b-8087c377f7db#6f38c2d5-f6ec-4485-8b38-08e7e3b0bb85rgoverhttp://social.msdn.microsoft.com/Profile/en-US/?user=rgoverCustom Role Provider Web Service<p align=left><font face=Arial size=2>Hey, I also implemented the RolerProvider in a web service, but I created a wrapper class around all the web service calls, and made  the wrapper class the Rolw provider. Heres the class</font></p> <p>  public class WSRoleProvider<img alt="Tongue Tied" src="http://forums.microsoft.com/MSDN/emoticons/emotion-7.gif">ystem.Web.Security.RoleProvider<br>    {<br>        private string applicationName;</p> <p>        public override string ApplicationName<br>        {<br>            get { return applicationName; }<br>            set { applicationName = value; }<br>        }<br>        private string providerName;</p> <p>        public string ProviderName<br>        {<br>            get { return providerName; }<br>            set { providerName = value; }<br>        }<br>        public static System.Net.ICredentials GetWSRoleProviderCredentials()<br>        {<br>            // credentials are stored as domain,user,pwd<br>            if (string.IsNullOrEmpty(Properties.Settings.Default.GbtuRoleProviderWebServiceCredentials))<br>            {<br>                string[] credentialString = Properties.Settings.Default.GbtuRoleProviderWebServiceCredentials.Split(','); <br>                System.Net.NetworkCredential credentials = new System.Net.NetworkCredential(credentialString[1], credentialString[2], credentialString[0]);<br>                return credentials;<br>            <br>            }<br>            // otherwise , use the Default Credentials <br>            //(delegation works we just need to get rid of the IDS from the config file)<br>            return System.Net.CredentialCache.DefaultCredentials;</p> <p>        }<br>        private VTU.Web_Applications.Gbtu.RoleProviderServiceProxy.RoleProvider GetRoleProviderProxy()<br>        {<br>            VTU.Web_Applications.Gbtu.RoleProviderServiceProxy.RoleProvider ws = new VTU.Web_Applications.Gbtu.RoleProviderServiceProxy.RoleProvider();<br>            ws.Credentials = GetWSRoleProviderCredentials();<br>            ws.Url = Properties.Settings.Default.VTU_Web_Applications_Gbtu_RoleProviderServiceProxy_RoleProvider;</p> <p>            return ws;<br>        }</p> <p>        public override void AddUsersToRoles(string[] usernames, string[] roleNames)<br>        {<br>            VTU.Web_Applications.Gbtu.RoleProviderServiceProxy.RoleProvider proxy = GetRoleProviderProxy();<br>            proxy.AddUsersToRoles( usernames, roleNames,HttpContext.Current.User.Identity.Name);</p> <p>        }</p> <p> </p> <p>        public override void CreateRole(string roleName)<br>        {<br>            throw new Exception(&quot;Function Create Role has nort been implemented. Just zap the databse&quot;);<br>            //VTU.Web_Applications.Gbtu.RoleProviderServiceProxy.RoleProvider proxy = GetRoleProviderProxy();<br>            //proxy.CreateRole(roleName, HttpContext.Current.User.Identity.Name);</p> <p>        }</p> <p>        public override bool DeleteRole(string roleName, bool throwOnPopulatedRole)<br>        {<br>            throw new Exception(&quot;Function Delete Role has nort been implemented. Just zap the databse&quot;);<br>          <br>            //VTU.Web_Applications.Gbtu.RoleProviderServiceProxy.RoleProvider proxy = GetRoleProviderProxy();<br>            //bool deleted = proxy.DeleteRole(roleName, throwOnPopulatedRole, HttpContext.Current.User.Identity.Name);<br>            //return deleted;<br>        }</p> <p>        public override string[] FindUsersInRole(string roleName, string usernameToMatch)<br>        {<br>            throw new Exception(&quot;Function FindUsersInRole Role has nort been implemented, if needed we can add it&quot;);<br>          <br>            //VTU.Web_Applications.Gbtu.RoleProviderServiceProxy.RoleProvider proxy = GetRoleProviderProxy();<br>            //string[] usersInRoles = proxy.FindUsersInRole(roleName, usernameToMatch);<br>            //return usersInRoles;<br>        }</p> <p>        public override string[] GetAllRoles()<br>        {<br>            VTU.Web_Applications.Gbtu.RoleProviderServiceProxy.RoleProvider proxy = GetRoleProviderProxy();<br>            string[] roles = proxy.GetAllRoles();<br>            return roles;</p> <p>        }</p> <p>        public override string[] GetRolesForUser(string username)<br>        {<br>            VTU.Web_Applications.Gbtu.RoleProviderServiceProxy.RoleProvider proxy = GetRoleProviderProxy();<br>            string[] rolesForUser = proxy.GetRolesForUser( username);<br>            return rolesForUser;</p> <p>        }</p> <p>        public string[] GetRolesForUser()<br>        {<br>            IPrincipal user = System.Web.HttpContext.Current.User;<br>            string username = user.Identity.Name;<br>            string[] rolesForUser = GetRolesForUser(username);<br>            return rolesForUser;</p> <p>        }</p> <p>        public override string[] GetUsersInRole(string roleName)<br>        {<br>            VTU.Web_Applications.Gbtu.RoleProviderServiceProxy.RoleProvider proxy = GetRoleProviderProxy();<br>            string[] usersInRole = proxy.GetUsersInRole( roleName);<br>            return usersInRole;</p> <p>        }<br>        public  DataSet GetUsersInRoleExtendedInfo(string roleName)<br>        {<br>            // the -1 is for consistincey in ddlb values where -1 = nothing<br>            if (String.IsNullOrEmpty(roleName) || roleName == &quot;-1&quot;)<br>                return null;<br>            VTU.Web_Applications.Gbtu.RoleProviderServiceProxy.RoleProvider proxy = GetRoleProviderProxy();<br>            DataSet  usersInRole = proxy.GetUsersInRoleExtendedInfo(roleName);<br>            return usersInRole;</p> <p>        }<br>        public DataView GetActiveUsersInRoleExtendedInfo(string roleName)<br>        {<br>            DataSet ds = GetUsersInRoleExtendedInfo(roleName);<br>            DataView dv = ds.Tables[0].DefaultView;<br>            dv.RowFilter = &quot;Active=true&quot;;<br>            return dv;</p> <p>        }</p> <p>        public override bool IsUserInRole(string username, string roleName)<br>        {<br>        roleName=roleName.ToLower();<br>           string[] rolesForUser= GetRolesForUser(username);<br>           foreach (string userrole in rolesForUser)<br>           {<br>               if (userrole.ToLower() == roleName)<br>                   return true;<br>           }<br>           return false;<br>           <br>        }<br>        public bool IsUserInRole(string roleName)<br>        {<br>            IPrincipal user = System.Web.HttpContext.Current.User;<br>            string username = user.Identity.Name;<br>            bool isUserInRole = IsUserInRole(username, roleName);<br>            return isUserInRole;</p> <p>        }<br>        public override void RemoveUsersFromRoles(string[] usernames, string[] roleNames)<br>        {<br>            VTU.Web_Applications.Gbtu.RoleProviderServiceProxy.RoleProvider proxy = GetRoleProviderProxy();<br>            proxy.RemoveUsersFromRoles( usernames, roleNames);<br>        }<br>        public void RemoveUserFromRole(string salesEmpUser, string roleName)<br>        {<br>            string[] userNames = new string[] { salesEmpUser };<br>string[] roleNames= new string[] {roleName};<br>            RemoveUsersFromRoles(userNames,roleNames);</p> <p>        }<br>        public void RemoveUserFromRoles(string[] roleNames)<br>        {<br>            IPrincipal user = System.Web.HttpContext.Current.User;<br>            string username = user.Identity.Name;<br>            string[] usernames = new string[] { username };<br>            RemoveUsersFromRoles(usernames, roleNames);</p> <p><br>        }</p> <p>        public override bool RoleExists(string roleName)<br>        {<br>            // need to do thios<br>            throw new Exception(&quot;Function IsUserInRole Role has nort been implemented, need to do this&quot;);<br>          <br>            //VTU.Web_Applications.Gbtu.RoleProviderServiceProxy.RoleProvider proxy = GetRoleProviderProxy();<br>            //bool roleExists = proxy.RoleExists( roleName);<br>            //return roleExists;<br>        }<br>    }</p> <p align=left> </p> <p align=left>Then in the web config</p><font color="#0000ff" size=2> <p>&lt;</font><font color="#a31515" size=2>roleManager</font><font color="#0000ff" size=2> </font><font color="#ff0000" size=2>enabled</font><font color="#0000ff" size=2>=</font><font size=2>&quot;</font><font color="#0000ff" size=2>true</font><font size=2>&quot;</font><font color="#0000ff" size=2> </font><font color="#ff0000" size=2>defaultProvider</font><font color="#0000ff" size=2>=</font><font size=2>&quot;</font><font color="#0000ff" size=2>WsRoleProvider</font><font size=2>&quot;</font><font color="#0000ff" size=2> </font><font color="#ff0000" size=2>cacheRolesInCookie</font><font color="#0000ff" size=2>=</font><font size=2>&quot;</font><font color="#0000ff" size=2>true</font><font size=2>&quot;</font><font color="#0000ff" size=2> </font><font color="#ff0000" size=2>cookieName</font><font color="#0000ff" size=2>=</font><font size=2>&quot;</font><font color="#0000ff" size=2>.ASPXROLES</font><font size=2>&quot;</font><font color="#0000ff" size=2> </font><font color="#ff0000" size=2>cookiePath</font><font color="#0000ff" size=2>=</font><font size=2>&quot;</font><font color="#0000ff" size=2>/</font><font size=2>&quot;</font><font color="#0000ff" size=2> </font><font color="#ff0000" size=2>cookieTimeout</font><font color="#0000ff" size=2>=</font><font size=2>&quot;</font><font color="#0000ff" size=2>30</font><font size=2>&quot;</font><font color="#0000ff" size=2> </font><font color="#ff0000" size=2>cookieRequireSSL</font><font color="#0000ff" size=2>=</font><font size=2>&quot;</font><font color="#0000ff" size=2>false</font><font size=2>&quot;</font><font color="#0000ff" size=2> </font><font color="#ff0000" size=2>cookieSlidingExpiration</font><font color="#0000ff" size=2>=</font><font size=2>&quot;</font><font color="#0000ff" size=2>true</font><font size=2>&quot;</font><font color="#0000ff" size=2> </font><font color="#ff0000" size=2>cookieProtection</font><font color="#0000ff" size=2>=</font><font size=2>&quot;</font><font color="#0000ff" size=2>All</font><font size=2>&quot;</font><font color="#0000ff" size=2>&gt;</p> <p>&lt;</font><font color="#a31515" size=2>providers</font><font color="#0000ff" size=2>&gt;</p> <p>&lt;</font><font color="#a31515" size=2>clear</font><font color="#0000ff" size=2>/&gt;</p> <p>&lt;</font><font color="#a31515" size=2>add</font><font color="#0000ff" size=2> </font><font color="#ff0000" size=2>name</font><font color="#0000ff" size=2>=</font><font size=2>&quot;</font><font color="#0000ff" size=2>WsRoleProvider</font><font size=2>&quot;</font><font color="#0000ff" size=2> </font><font color="#ff0000" size=2>type</font><font color="#0000ff" size=2>=</font><font size=2>&quot;VTU</font><font color="#0000ff" size=2>.Web_Applications.Gbtu.Classes.WSRoleProvider</font><font size=2>&quot;</font><font color="#0000ff" size=2> </font><font color="#ff0000" size=2>applicationName</font><font color="#0000ff" size=2>=</font><font size=2>&quot;</font><font color="#0000ff" size=2>Gtbu</font><font size=2>&quot;</font><font color="#0000ff" size=2>/&gt;</p> <p>&lt;</font><font color="#a31515" size=2>add</font><font color="#0000ff" size=2> </font><font color="#ff0000" size=2>name</font><font color="#0000ff" size=2>=</font><font size=2>&quot;</font><font color="#0000ff" size=2>WindowsProvider</font><font size=2>&quot;</font><font color="#0000ff" size=2> </font><font color="#ff0000" size=2>type</font><font color="#0000ff" size=2>=</font><font size=2>&quot;</font><font color="#0000ff" size=2>System.Web.Security.WindowsTokenRoleProvider</font><font size=2>&quot;</font><font color="#0000ff" size=2> /&gt;</p> <p>&lt;/</font><font color="#a31515" size=2>providers</font><font color="#0000ff" size=2>&gt;</p></font>Thu, 04 Oct 2007 20:27:50 Z2007-10-04T20:27:50Zhttp://social.msdn.microsoft.com/Forums/en-US/asmxandxml/thread/b06554d9-c1c4-4b7f-840b-8087c377f7db#2481093e-0eaa-4184-99d6-abdfbe7623d7http://social.msdn.microsoft.com/Forums/en-US/asmxandxml/thread/b06554d9-c1c4-4b7f-840b-8087c377f7db#2481093e-0eaa-4184-99d6-abdfbe7623d7Kalebhttp://social.msdn.microsoft.com/Profile/en-US/?user=KalebCustom Role Provider Web ServiceSorry for the delayed response, John;<br><br>The code presented on that page does not implement the RoleProvider Class (unless I'm missing something), which means I can't reference it directly from the web.config, at least not in any way I've found. I've got it setup where I'm implementing a role provider which then calls webservice methods, but I want to be able to just reference the web service as a role provider.<br>Thu, 04 Oct 2007 20:50:40 Z2007-10-04T20:50:40Zhttp://social.msdn.microsoft.com/Forums/en-US/asmxandxml/thread/b06554d9-c1c4-4b7f-840b-8087c377f7db#37e4311e-e246-4a00-96d6-c279d997c389http://social.msdn.microsoft.com/Forums/en-US/asmxandxml/thread/b06554d9-c1c4-4b7f-840b-8087c377f7db#37e4311e-e246-4a00-96d6-c279d997c389John Saundershttp://social.msdn.microsoft.com/Profile/en-US/?user=John%20SaundersCustom Role Provider Web Service<p> <div class=quote> <table width="85%"> <tbody> <tr> <td class=txt4> <strong>Kaleb wrote:</strong></td></tr> <tr> <td class=quoteTable> <table width="100%"> <tbody> <tr> <td class=txt4 valign=top width="100%"> <p></p> <p align=left>The code presented on that page does not implement the RoleProvider Class (unless I'm missing something),</p> <p align=left></p></td></tr></tbody></table></td></tr></tbody></table></div> <p></p> <p> </p> <p align=left>Yeah, I think you're missing something. Did you download the code and look at it? </p> <p align=left> </p> <p align=left>The role provider class starts like this:</p> <p align=left> </p> <p align=left> <div class=codeseg> <div class=codecontent> <div class=codesniptitle><span style="width:100%">Code Block</span></div> <p align=left>  sealed public class WebServiceRoleProvider : System.Web.Security.RoleProvider<br></p> <p align=left> </p></div></div> <p align=left> </p> <p></p>Thu, 04 Oct 2007 21:06:18 Z2007-10-04T21:06:18Zhttp://social.msdn.microsoft.com/Forums/en-US/asmxandxml/thread/b06554d9-c1c4-4b7f-840b-8087c377f7db#b62e06cc-da12-4738-b849-d722c55a51a0http://social.msdn.microsoft.com/Forums/en-US/asmxandxml/thread/b06554d9-c1c4-4b7f-840b-8087c377f7db#b62e06cc-da12-4738-b849-d722c55a51a0Kalebhttp://social.msdn.microsoft.com/Profile/en-US/?user=KalebCustom Role Provider Web Service<p>Right, but I'm wanting to define the role provider class in the web service. At one point, I was able to get the web.config to accept the webservice as the roleprovider, but it threw an error that the webservice wasn't implementing the roleprovider class. And maybe what I'm trying to do is refactor a little too much.</p> <p align=left> </p> <p align=left>I tried implementing a role provider in my application (as it's done in the CP article), but couldn't get the type specified properly in the web.config (I defined it in a separate project so I could keep my layers segregated - I classify Security as more BLL then Presentation Layer).</p> <p> </p> <p align=left>Your help is greatly appreciated.</p>Fri, 05 Oct 2007 19:44:18 Z2007-10-05T19:44:18Zhttp://social.msdn.microsoft.com/Forums/en-US/asmxandxml/thread/b06554d9-c1c4-4b7f-840b-8087c377f7db#bfca0175-5a21-4e7c-a12c-4aad6966eb86http://social.msdn.microsoft.com/Forums/en-US/asmxandxml/thread/b06554d9-c1c4-4b7f-840b-8087c377f7db#bfca0175-5a21-4e7c-a12c-4aad6966eb86Kalebhttp://social.msdn.microsoft.com/Profile/en-US/?user=KalebCustom Role Provider Web Servicergover - I believe this implemntation is similar to the CP article as well. I do appreciate you pasting your full source, but I'm trying to take it to the next step and not have to implement the proxy/wrapper class. <p align=left> </p>Fri, 05 Oct 2007 19:46:40 Z2007-10-05T19:46:40Zhttp://social.msdn.microsoft.com/Forums/en-US/asmxandxml/thread/b06554d9-c1c4-4b7f-840b-8087c377f7db#6f47cc04-00ce-42f2-9674-e9ea349ee955http://social.msdn.microsoft.com/Forums/en-US/asmxandxml/thread/b06554d9-c1c4-4b7f-840b-8087c377f7db#6f47cc04-00ce-42f2-9674-e9ea349ee955John Saundershttp://social.msdn.microsoft.com/Profile/en-US/?user=John%20SaundersCustom Role Provider Web Service<div class=quote> <table width="85%"> <tbody> <tr> <td class=txt4> <strong>Kaleb wrote:</strong></td></tr> <tr> <td class=quoteTable> <table width="100%"> <tbody> <tr> <td class=txt4 valign=top width="100%"> <p>Right, but I'm wanting to define the role provider class in the web service. At one point, I was able to get the web.config to accept the webservice as the roleprovider, but it threw an error that the webservice wasn't implementing the roleprovider class. And maybe what I'm trying to do is refactor a little too much.</p> <p></p></td></tr></tbody></table></td></tr></tbody></table></div> <p></p> <p align=left> </p> <p align=left>I just got what you're trying to do.</p> <p align=left> </p> <p align=left>You're confusing the client and the server. In this context, your web application is a client to the web service.</p> <p align=left> </p> <p align=left>You have added a Web Reference to your web application and called it &quot;RoleProvider&quot;. This creates a proxy class called &quot;RoleProvider.CustomRoleProviderWebService&quot; (the namespace &quot;WebService&quot; is irrelevant). This class derives from SoapHttpClientProtocol, not whatever your web service derives from.</p> <p align=left> </p> <p align=left>The proxy class is <em>not</em> the same thing as the server class, and it never will be. It's just a convenient way for you to call the web service. It's not the web service class itself. Even if you derived your web service class from System.Web.Security.RoleProvider, your proxy class would still derive from SoapHttpClientProtocol.</p> <p align=left> </p> <p align=left>So, I'm sorry, but you need to use a wrapper.</p>Fri, 05 Oct 2007 23:14:41 Z2007-10-15T16:37:24Zhttp://social.msdn.microsoft.com/Forums/en-US/asmxandxml/thread/b06554d9-c1c4-4b7f-840b-8087c377f7db#2d3d8a92-a230-4cf3-9df3-c20d103ddf20http://social.msdn.microsoft.com/Forums/en-US/asmxandxml/thread/b06554d9-c1c4-4b7f-840b-8087c377f7db#2d3d8a92-a230-4cf3-9df3-c20d103ddf20Kalebhttp://social.msdn.microsoft.com/Profile/en-US/?user=KalebCustom Role Provider Web ServiceThank you for your response, John. <font face=Arial size=2>Now that I know 100% that I have to use a wrapper, I'll adjust my code accordingly. <img alt=Smile src="http://forums.microsoft.com/MSDN/emoticons/emotion-1.gif"></font>Mon, 15 Oct 2007 16:33:44 Z2007-10-15T16:33:44Z