mpatrick65
asked on
Custom Profile Provider Deployed to Win 2008 64 Bit, IIS 7 .net 3.5 Error: Could not load type 'MyApp.MyRoleProvider'.
I am trying to deploy our application to our new enviroment. We have Win 2008 64bit servers. I have a suspicion that it may be related to this. The application works perfectly on my Dev Enviroment. We use custom Membership, Roles & Profiles. Here is the 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: Could not load type 'PromoRegistration.PRCRole Provider'.
Source Error:
Line 212: <providers>
Line 213: <clear/>
Line 214: <add name="PRCRoleProvider" type="PromoRegistration.PR CRoleProvi der" connectionStringName="PRCC onnectionS tring" applicationName="PromoRegi stration"/ >
Line 215: </providers>
Line 216: </roleManager>
Source File: C:\wwwPub\PromoRegistratio n\web.conf ig Line: 214
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: Could not load type 'PromoRegistration.PRCRole
Source Error:
Line 212: <providers>
Line 213: <clear/>
Line 214: <add name="PRCRoleProvider" type="PromoRegistration.PR
Line 215: </providers>
Line 216: </roleManager>
Source File: C:\wwwPub\PromoRegistratio
Web.Config:
<?xml version="1.0"?><configuration>
<configSections>
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/>
<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
<section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
</sectionGroup>
</sectionGroup>
</sectionGroup>
</configSections>
<!--
The system.webServer section is required for running ASP.NET AJAX under Internet
Information Services 7.0. It is not necessary for previous version of IIS.
-->
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules>
<remove name="ScriptModule" />
<add name="CuteWebUI.UploadModule" type="CuteWebUI.UploadModule,CuteWebUI.AjaxUploader"/>
<add name="CuteEditor.UploadModule" type="CuteEditor.UploadModule,CuteEditor"/>
<add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</modules>
<handlers>
<remove name="WebServiceHandlerFactory-Integrated" />
<remove name="ScriptHandlerFactory" />
<remove name="ScriptHandlerFactoryAppServices" />
<remove name="ScriptResource" />
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add name="CrystalImageHandler.aspx_GET" verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" preCondition="integratedMode" />
</handlers>
<defaultDocument>
<files>
<add value="home.aspx" />
</files>
</defaultDocument>
</system.webServer>
<!--Set anonymous user page view permissions-->
<!--
<location path="become_client.aspx">
<system.web>
<authorization>
<allow roles="Administrator"/>
<deny users="*" />
</authorization>
</system.web>
</location>
-->
<appSettings>
<add key="Pronto_Account" value="Default" />
<add key="Pronto_Password" value="Password" />
<add key="Pronto_PageTitle" value="PromoRegistration.com" />
<!--
<add key="Pronto_HttpHost" value="https://www.insta-sign.com/" />
-->
<add key="Pronto_HttpHost" value="http://insta-signdev/" />
<add key="Pronto_TestEmail" value="vjuri@HCCsu.com" />
<add key="Pronto_AppErrorEmailAddress" value="vjuri@HCCsu.com" />
<add key="Pronto_MailPickupPath" value="C:\Inetpub\mailroot\Pickup" />
<add key="Pronto_ProntoDirectory" value="C:\AlphaTrust\Pronto\" />
<add key="Pronto_Environment" value="dev" />
<add key="SMTPServer" value="hctx-ex02" />
<add key="FromAddress" value="support@promoregistration.com" />
<add key="CrystalImageCleaner-AutoStart" value="true" />
<add key="CrystalImageCleaner-Sleep" value="60000" />
<add key="CrystalImageCleaner-Age" value="120000" />
<add key="CuteWebUI.AjaxUploader.TempDirectory" value="~/UploadedFiles"/>
<add key="CuteWebUI.AjaxUploader.GlobalMaxSizeKB" value="1000"/>
<add key="AjaxUploaderLicense" value="~/bin/AjaxUploader.lic" />
</appSettings>
<connectionStrings>
<remove name="LocalSqlServer"/>
<add name="PRCConnectionString_Off" connectionString="Data Source=ASMA-PXCORDLF1\SQLEXPRESS;Initial Catalog=PromoRegistration;User Id=SQLUser; Pooling=false; Password=998236594;Connect Timeout=60;" providerName="System.Data.SqlClient" />
<add name="PRCInvoiceLineItems_Off" connectionString="Data Source=ASMA-PXCORDLF1\SQLEXPRESS;Initial Catalog=PromoRegistration;Integrated Security=True" providerName="System.Data.SqlClient" />
<add name="PRCConnectionString" connectionString="Data Source=Hcdc-websql01;Initial Catalog=PromoRegistration;User Id=SQLUser; Pooling=false; Password=998236594Vj!;Connect Timeout=60;" providerName="System.Data.SqlClient" />
<add name="PRCInvoiceLineItems" connectionString="Data Source=Hcdc-websql01;Initial Catalog=PromoRegistration;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
<system.net>
<mailSettings>
<smtp from="support@promoregistration.com">
<network host="hctx-ex02" password="" userName=""/>
</smtp>
</mailSettings>
</system.net>
<system.web>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
Visual Basic options:
Set strict="true" to disallow all data type conversions
where data loss can occur.
Set explicit="true" to force declaration of all variables.
-->
<compilation debug="true" strict="false" explicit="true">
<assemblies>
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Web.Extensions.Design, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Services, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.DirectoryServices.Protocols, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.EnterpriseServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.ServiceProcess, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Web.RegularExpressions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="CrystalDecisions.Web, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
<add assembly="CrystalDecisions.Shared, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
<add assembly="CrystalDecisions.ReportSource, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
<add assembly="CrystalDecisions.CrystalReports.Engine, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
<add assembly="CrystalDecisions.ReportAppServer.ClientDoc, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
<add assembly="CrystalDecisions.Enterprise.Framework, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
<add assembly="CrystalDecisions.Enterprise.InfoStore, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
</assemblies>
</compilation>
<pages>
<namespaces>
<clear/>
<add namespace="System"/>
<add namespace="System.Collections"/>
<add namespace="System.Collections.Generic"/>
<add namespace="System.Collections.Specialized"/>
<add namespace="System.Configuration"/>
<add namespace="System.Text"/>
<add namespace="System.Text.RegularExpressions"/>
<add namespace="System.Linq"/>
<add namespace="System.Xml.Linq"/>
<add namespace="System.Web"/>
<add namespace="System.Web.Caching"/>
<add namespace="System.Web.SessionState"/>
<add namespace="System.Web.Security"/>
<add namespace="System.Web.Profile"/>
<add namespace="System.Web.UI"/>
<add namespace="System.Web.UI.WebControls"/>
<add namespace="System.Web.UI.WebControls.WebParts"/>
<add namespace="System.Web.UI.HtmlControls"/>
<add namespace="AlphaTrust" />
</namespaces>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</controls>
</pages>
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<authentication mode="Forms">
<forms loginUrl="home.aspx" path="/" name=".ASPXFORMSAUTH" protection="All" slidingExpiration="true" />
</authentication>
<authorization>
<allow users="?"/>
</authorization>
<machineKey validationKey="C50B3C89CB21F4F1422FF158A5B42D0E8DB8CB5CDA1742572A487D9401E3400267682B202B746511891C1BAF47F8D25C07F6C39A104696DB51F17C529AD3CABE" decryptionKey="8A9BE8FD67AF6979E7D20198CFEA50DD3D3799C77AF2B72F" validation="SHA1"/>
<anonymousIdentification enabled="true"/>
<!--SiteMap Provider Configuration-->
<siteMap defaultProvider="AspNetXmlSiteMapProvider">
<providers>
<add name="AdminSiteMap" type="System.Web.XmlSiteMapProvider" siteMapFile="~/Admin/Admin.sitemap"/>
<add name="ApplicationSiteMap" type="System.Web.XmlSiteMapProvider" siteMapFile="~/Application/Application.sitemap"/>
<add name="ClientSiteMap" type="System.Web.XmlSiteMapProvider" siteMapFile="~/ClientArea/Client.sitemap"/>
<add name="ClientUserSiteMap" type="System.Web.XmlSiteMapProvider" siteMapFile="~/ClientArea/ClientUser.sitemap"/>
</providers>
</siteMap>
<!--Custom Membership Provider Configuration-->
<membership defaultProvider="PRCMembershipProvider" userIsOnlineTimeWindow="15">
<providers>
<clear/>
<add name="PRCMembershipProvider" type="PromoRegistration.PRCMembershipProvider" connectionStringName="PRCConnectionString" enablePasswordRetrieval="true" enablePasswordReset="true" requiresQuestionAndAnswer="false" writeExceptionsToEventLog="false" requiresUniqueEmail="true" passwordFormat="Encrypted" applicationName="PromoRegistration"/>
</providers>
</membership>
<!--Custom Roles Provider Configuration-->
<roleManager defaultProvider="PRCRoleProvider" enabled="true" cacheRolesInCookie="true">
<providers>
<clear/>
<add name="PRCRoleProvider" type="PromoRegistration.PRCRoleProvider" connectionStringName="PRCConnectionString" applicationName="PromoRegistration"/>
</providers>
</roleManager>
<!--Profile Provider Configuration-->
<profile defaultProvider="PRCSqlProvider">
<providers>
<clear/>
<add name="PRCSqlProvider" type="PromoRegistration.PRCProfileProvider" connectionStringName="PRCConnectionString" applicationName="PromoRegistration"/>
</providers>
<properties>
<add name="LogInId" type="System.Int32" allowAnonymous="true"/>
<add name="ApplicationType" type="System.String" allowAnonymous="true"/>
<add name="CompanyId" type="System.Int32" allowAnonymous="true"/>
<add name="FirstName" type="System.String" allowAnonymous="true"/>
<add name="LastName" type="System.String" allowAnonymous="true"/>
<add name="Email" type="System.String" allowAnonymous="true"/>
<add name="Title" type="System.String" allowAnonymous="true"/>
<add name="PhoneAc" type="System.String" allowAnonymous="true"/>
<add name="PhoneSuf" type="System.String" allowAnonymous="true"/>
<add name="PhonePost" type="System.String" allowAnonymous="true"/>
<add name="PhoneExt" type="System.String" allowAnonymous="true"/>
<add name="CompanyName" type="System.String" allowAnonymous="true"/>
<add name="StOther" type="System.String" allowAnonymous="true"/>
<add name="CountryOther" type="System.String" allowAnonymous="true"/>
<add name="Address" type="System.String" allowAnonymous="true"/>
<add name="Address2" type="System.String" allowAnonymous="true"/>
<add name="City" type="System.String" allowAnonymous="true"/>
<add name="St" type="System.String" allowAnonymous="true"/>
<add name="Zip" type="System.String" allowAnonymous="true"/>
<add name="Country" type="System.String" allowAnonymous="true"/>
<add name="EmailOptIn" type="System.Boolean" allowAnonymous="true"/>
</properties>
</profile>
<!--
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,
it enables developers to configure html error pages
to be displayed in place of a error stack trace.
-->
<customErrors mode="Off" defaultRedirect="Error.aspx">
<error statusCode="403" redirect="error.aspx"/>
<error statusCode="404" redirect="FileNotFound.aspx"/>
</customErrors>
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
<add verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
</httpHandlers>
<httpModules>
<add name="CuteWebUI.UploadModule" type="CuteWebUI.UploadModule,CuteWebUI.AjaxUploader"/>
<add name="CuteEditor.UploadModule" type="CuteEditor.UploadModule,CuteEditor"/>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</httpModules>
</system.web>
<system.codedom>
<compilers>
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warningLevel="4" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<providerOption name="CompilerVersion" value="v3.5"/>
<providerOption name="OptionInfer" value="true"/>
<providerOption name="WarnAsError" value="false"/>
</compiler>
</compilers>
</system.codedom>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Role Provider:
Imports System.Web.Security
Imports System.Configuration.Provider
Imports System.Collections.Specialized
Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.Odbc
Imports System.Configuration
Imports System.Diagnostics
Imports System.Web
Imports System.Globalization
Imports Microsoft.VisualBasic
'
'
' This provider works with the following schema for the tables of role data.
'
' CREATE TABLE Roles
' (
' Rolename Text (255) NOT NULL,
' ApplicationName Text (255) NOT NULL,
' CONSTRAINT PKRoles PRIMARY KEY (Rolename, ApplicationName)
' )
'
' CREATE TABLE UsersInRoles
' (
' Username Text (255) NOT NULL,
' Rolename Text (255) NOT NULL,
' ApplicationName Text (255) NOT NULL,
' CONSTRAINT PKUsersInRoles PRIMARY KEY (Username, Rolename, ApplicationName)
' )
'
'
Public Class PRCRoleProvider
Inherits System.Web.Security.RoleProvider
#Region "Class Variables"
' Global OdbcConnection, generated password length, generic exception message, event log info.
Private conn As OdbcConnection
Private eventSource As String = "OdbcRoleProvider"
Private eventLog As String = "Application"
Private exceptionMessage As String = "An exception occurred. Please check the Event Log."
Private pConnectionStringSettings As ConnectionStringSettings
Private connectionString As String
' If false, exceptions are Thrown to the caller. If true, exceptions are written to the event log.
Private pWriteExceptionsToEventLog As Boolean = False
Private pApplicationName As String
#End Region
#Region "Properties"
Public Property WriteExceptionsToEventLog() As Boolean
Get
Return pWriteExceptionsToEventLog
End Get
Set(ByVal value As Boolean)
pWriteExceptionsToEventLog = value
End Set
End Property
Public Overrides Property ApplicationName() As String
Get
Return pApplicationName
End Get
Set(ByVal value As String)
pApplicationName = value
End Set
End Property
#End Region
' System.Configuration.Provider.ProviderBase.Initialize Method
Public Overrides Sub Initialize(ByVal name As String, ByVal config As NameValueCollection)
' Initialize values from web.config.
If config Is Nothing Then
Throw New ArgumentNullException("config")
End If
If name Is Nothing OrElse name.Length = 0 Then
name = "PRCRoleProvider"
End If
If String.IsNullOrEmpty(config("description")) Then
config.Remove("description")
config.Add("description", "PRC SQL Role provider")
End If
' Initialize the abstract base class.
MyBase.Initialize(name, config)
If config("applicationName") Is Nothing OrElse config("applicationName").Trim() = "" Then
pApplicationName = System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath
Else
pApplicationName = config("applicationName")
End If
If Not config("writeExceptionsToEventLog") Is Nothing Then
If config("writeExceptionsToEventLog").ToUpper() = "TRUE" Then
pWriteExceptionsToEventLog = True
End If
End If
' Initialize OdbcConnection.
pConnectionStringSettings = ConfigurationManager.ConnectionStrings(config("connectionStringName"))
If pConnectionStringSettings Is Nothing OrElse pConnectionStringSettings.ConnectionString.Trim() = "" Then
Throw New ProviderException("Connection string cannot be blank.")
End If
connectionString = pConnectionStringSettings.ConnectionString
End Sub
' RoleProvider.AddUsersToRoles
Public Overrides Sub AddUsersToRoles(ByVal usernames As String(), ByVal rolenames As String())
For Each rolename As String In rolenames
If Not RoleExists(rolename) Then
Throw New ProviderException("Role name not found.")
End If
Next
For Each username As String In usernames
If username.Contains(",") Then
Throw New ArgumentException("User names cannot contain commas.")
End If
For Each rolename As String In rolenames
If IsUserInRole(username, rolename) Then
Throw New ProviderException("User is already in role.")
End If
Next
Next
If pConnectionStringSettings Is Nothing OrElse pConnectionStringSettings.ConnectionString.Trim() = "" Then
pConnectionStringSettings = ConfigurationManager.ConnectionStrings("PRCConnectionString")
connectionString = pConnectionStringSettings.ConnectionString
End If
If ApplicationName Is Nothing Or ApplicationName = "" Then
ApplicationName = "PromoRegistration"
End If
Dim _sqlConnection As SqlConnection = New SqlConnection(connectionString)
Dim _sqlCommand As SqlCommand = New SqlCommand("Roles_AddUsersToRoles", _sqlConnection)
Dim userParm As SqlParameter = _sqlCommand.Parameters.Add("@Username", SqlDbType.NVarChar, 255)
Dim roleParm As SqlParameter = _sqlCommand.Parameters.Add("@Rolename", SqlDbType.NVarChar, 255)
_sqlCommand.Parameters.Add("@applicationName", SqlDbType.NVarChar, 255).Value = ApplicationName
Dim tran As SqlTransaction = Nothing
Try
_sqlConnection.Open()
tran = _sqlConnection.BeginTransaction()
_sqlCommand.Transaction = tran
For Each username As String In usernames
For Each rolename As String In rolenames
userParm.Value = username
roleParm.Value = rolename
_sqlCommand.ExecuteNonQuery()
Next
Next
tran.Commit()
Catch e As SqlException
Try
tran.Rollback()
Catch
End Try
If WriteExceptionsToEventLog Then
WriteToEventLog(e, "AddUsersToRoles")
Else
Throw e
End If
Finally
_sqlConnection.Close()
End Try
End Sub
' RoleProvider.CreateRole
Public Overrides Sub CreateRole(ByVal rolename As String)
If rolename.Contains(",") Then
Throw New ArgumentException("Role names cannot contain commas.")
End If
If RoleExists(rolename) Then
Throw New ProviderException("Role name already exists.")
End If
If pConnectionStringSettings Is Nothing OrElse pConnectionStringSettings.ConnectionString.Trim() = "" Then
pConnectionStringSettings = ConfigurationManager.ConnectionStrings("PRCConnectionString")
connectionString = pConnectionStringSettings.ConnectionString
End If
If ApplicationName Is Nothing Or ApplicationName = "" Then
ApplicationName = "PromoRegistration"
End If
Dim _sqlConnection As SqlConnection = New SqlConnection(connectionString)
Dim _sqlCommand As SqlCommand = New SqlCommand("Roles_CreateRole", _sqlConnection)
_sqlCommand.CommandType = CommandType.StoredProcedure
_sqlCommand.Parameters.Add("@Rolename", SqlDbType.NVarChar, 255).Value = rolename
_sqlCommand.Parameters.Add("@applicationName", SqlDbType.NVarChar, 255).Value = ApplicationName
Try
_sqlConnection.Open()
_sqlCommand.ExecuteNonQuery()
Catch e As SqlException
If WriteExceptionsToEventLog Then
WriteToEventLog(e, "CreateRole")
Else
Throw e
End If
Finally
_sqlConnection.Close()
End Try
End Sub
' RoleProvider.DeleteRole
Public Overrides Function DeleteRole(ByVal rolename As String, ByVal throwOnPopulatedRole As Boolean) As Boolean
If Not RoleExists(rolename) Then
Throw New ProviderException("Role does not exist.")
End If
If throwOnPopulatedRole AndAlso GetUsersInRole(rolename).Length > 0 Then
Throw New ProviderException("Cannot delete a populated role.")
End If
If pConnectionStringSettings Is Nothing OrElse pConnectionStringSettings.ConnectionString.Trim() = "" Then
pConnectionStringSettings = ConfigurationManager.ConnectionStrings("PRCConnectionString")
connectionString = pConnectionStringSettings.ConnectionString
End If
If ApplicationName Is Nothing Or ApplicationName = "" Then
ApplicationName = "PromoRegistration"
End If
Dim _sqlConnection As SqlConnection = New SqlConnection(connectionString)
Dim _sqlCommand As SqlCommand = New SqlCommand("Roles_DeleteRole", _sqlConnection)
_sqlCommand.CommandType = CommandType.StoredProcedure
_sqlCommand.Parameters.Add("@Rolename", SqlDbType.NVarChar, 255).Value = rolename
_sqlCommand.Parameters.Add("@applicationName", SqlDbType.NVarChar, 255).Value = ApplicationName
Dim tran As SqlTransaction = Nothing
Try
_sqlConnection.Open()
tran = _sqlConnection.BeginTransaction()
_sqlCommand.Transaction = tran
_sqlCommand.ExecuteNonQuery()
tran.Commit()
Catch e As SqlException
Try
tran.Rollback()
Catch
End Try
If WriteExceptionsToEventLog Then
WriteToEventLog(e, "DeleteRole")
Return False
Else
Throw e
End If
Finally
_sqlConnection.Close()
End Try
Return True
End Function
' RoleProvider.GetAllRoles
Public Overrides Function GetAllRoles() As String()
Dim tmpRoleNames As String = ""
If pConnectionStringSettings Is Nothing OrElse pConnectionStringSettings.ConnectionString.Trim() = "" Then
pConnectionStringSettings = ConfigurationManager.ConnectionStrings("PRCConnectionString")
connectionString = pConnectionStringSettings.ConnectionString
End If
If ApplicationName Is Nothing Or ApplicationName = "" Then
ApplicationName = "PromoRegistration"
End If
Dim _sqlConnection As SqlConnection = New SqlConnection(connectionString)
Dim _sqlCommand As SqlCommand = New SqlCommand("Roles_GetAllRoles", _sqlConnection)
_sqlCommand.CommandType = CommandType.StoredProcedure
_sqlCommand.Parameters.Add("@applicationName", SqlDbType.NVarChar, 255).Value = ApplicationName
Dim _sqlDataReader As SqlDataReader = Nothing
Try
_sqlConnection.Open()
_sqlDataReader = _sqlCommand.ExecuteReader()
Do While _sqlDataReader.Read()
tmpRoleNames &= _sqlDataReader.GetString(0) & ","
Loop
Catch e As SqlException
If WriteExceptionsToEventLog Then
WriteToEventLog(e, "GetAllRoles")
Else
Throw e
End If
Finally
If Not _sqlDataReader Is Nothing Then _sqlDataReader.Close()
_sqlConnection.Close()
End Try
If tmpRoleNames.Length > 0 Then
' Remove trailing comma.
tmpRoleNames = tmpRoleNames.Substring(0, tmpRoleNames.Length - 1)
Return tmpRoleNames.Split(CChar(","))
End If
Return New String() {}
End Function
' RoleProvider.GetRolesForUser
Public Overrides Function GetRolesForUser(ByVal username As String) As String()
Dim tmpRoleNames As String = ""
If pConnectionStringSettings Is Nothing OrElse pConnectionStringSettings.ConnectionString.Trim() = "" Then
pConnectionStringSettings = ConfigurationManager.ConnectionStrings("PRCConnectionString")
connectionString = pConnectionStringSettings.ConnectionString
End If
If ApplicationName Is Nothing Or ApplicationName = "" Then
ApplicationName = "PromoRegistration"
End If
Dim _sqlConnection As SqlConnection = New SqlConnection(connectionString)
Dim _sqlCommand As SqlCommand = New SqlCommand("Roles_GetRolesForUser", _sqlConnection)
_sqlCommand.CommandType = CommandType.StoredProcedure
_sqlCommand.Parameters.Add("@Username", SqlDbType.NVarChar, 255).Value = username
_sqlCommand.Parameters.Add("@applicationName", SqlDbType.NVarChar, 255).Value = ApplicationName
Dim _sqlDataReader As SqlDataReader = Nothing
Try
_sqlConnection.Open()
_sqlDataReader = _sqlCommand.ExecuteReader(CommandBehavior.CloseConnection)
Do While _sqlDataReader.Read()
tmpRoleNames &= _sqlDataReader.GetString(0) & ","
Loop
Catch e As SqlException
If WriteExceptionsToEventLog Then
WriteToEventLog(e, "GetRolesForUser")
Else
Throw e
End If
Finally
If Not _sqlDataReader Is Nothing Then _sqlDataReader.Close()
_sqlConnection.Close()
End Try
If tmpRoleNames.Length > 0 Then
' Remove trailing comma.
tmpRoleNames = tmpRoleNames.Substring(0, tmpRoleNames.Length - 1)
Return tmpRoleNames.Split(CChar(","))
End If
Return New String() {}
End Function
' RoleProvider.GetUsersInRole
Public Overrides Function GetUsersInRole(ByVal rolename As String) As String()
Dim tmpUserNames As String = ""
If pConnectionStringSettings Is Nothing OrElse pConnectionStringSettings.ConnectionString.Trim() = "" Then
pConnectionStringSettings = ConfigurationManager.ConnectionStrings("PRCConnectionString")
connectionString = pConnectionStringSettings.ConnectionString
End If
If ApplicationName Is Nothing Or ApplicationName = "" Then
ApplicationName = "PromoRegistration"
End If
Dim _sqlConnection As SqlConnection = New SqlConnection(connectionString)
Dim _sqlCommand As SqlCommand = New SqlCommand("Roles_GetUsersInRole", _sqlConnection)
_sqlCommand.CommandType = CommandType.StoredProcedure
_sqlCommand.Parameters.Add("@Rolename", SqlDbType.NVarChar, 255).Value = rolename
_sqlCommand.Parameters.Add("@applicationName", SqlDbType.NVarChar, 255).Value = ApplicationName
Dim _sqlDataReader As SqlDataReader = Nothing
Try
_sqlConnection.Open()
_sqlDataReader = _sqlCommand.ExecuteReader(CommandBehavior.CloseConnection)
Do While _sqlDataReader.Read()
tmpUserNames &= _sqlDataReader.GetString(0) & ","
Loop
Catch e As SqlException
If WriteExceptionsToEventLog Then
WriteToEventLog(e, "GetUsersInRole")
Else
Throw e
End If
Finally
If Not _sqlDataReader Is Nothing Then _sqlDataReader.Close()
_sqlConnection.Close()
End Try
If tmpUserNames.Length > 0 Then
' Remove trailing comma.
tmpUserNames = tmpUserNames.Substring(0, tmpUserNames.Length - 1)
Return tmpUserNames.Split(CChar(","))
End If
Return New String() {}
End Function
' RoleProvider.IsUserInRole
Public Overrides Function IsUserInRole(ByVal username As String, ByVal rolename As String) As Boolean
Dim userIsInRole As Boolean = False
If pConnectionStringSettings Is Nothing OrElse pConnectionStringSettings.ConnectionString.Trim() = "" Then
pConnectionStringSettings = ConfigurationManager.ConnectionStrings("PRCConnectionString")
connectionString = pConnectionStringSettings.ConnectionString
End If
If ApplicationName Is Nothing Or ApplicationName = "" Then
ApplicationName = "PromoRegistration"
End If
Dim _sqlConnection As SqlConnection = New SqlConnection(connectionString)
Dim _sqlCommand As SqlCommand = New SqlCommand("Roles_IsUserInRole", _sqlConnection)
_sqlCommand.CommandType = CommandType.StoredProcedure
_sqlCommand.Parameters.Add("@Username", SqlDbType.NVarChar, 255).Value = username
_sqlCommand.Parameters.Add("@Rolename", SqlDbType.NVarChar, 255).Value = rolename
_sqlCommand.Parameters.Add("@applicationName", SqlDbType.NVarChar, 255).Value = ApplicationName
Try
_sqlConnection.Open()
Dim numRecs As Integer = CType(_sqlCommand.ExecuteScalar(), Integer)
If numRecs > 0 Then
userIsInRole = True
End If
Catch e As SqlException
If WriteExceptionsToEventLog Then
WriteToEventLog(e, "IsUserInRole")
Else
Throw e
End If
Finally
_sqlConnection.Close()
End Try
Return userIsInRole
End Function
' RoleProvider.RemoveUsersFromRoles
Public Overrides Sub RemoveUsersFromRoles(ByVal usernames As String(), ByVal rolenames As String())
For Each rolename As String In rolenames
If Not RoleExists(rolename) Then
Throw New ProviderException("Role name not found.")
End If
Next
For Each username As String In usernames
For Each rolename As String In rolenames
If Not IsUserInRole(username, rolename) Then
Throw New ProviderException("User is not in role.")
End If
Next
Next
If pConnectionStringSettings Is Nothing OrElse pConnectionStringSettings.ConnectionString.Trim() = "" Then
pConnectionStringSettings = ConfigurationManager.ConnectionStrings("PRCConnectionString")
connectionString = pConnectionStringSettings.ConnectionString
End If
If ApplicationName Is Nothing Or ApplicationName = "" Then
ApplicationName = "PromoRegistration"
End If
Dim _sqlConnection As SqlConnection = New SqlConnection(connectionString)
Dim _sqlCommand As SqlCommand = New SqlCommand("Roles_RemoveUsersFromRoles", _sqlConnection)
Dim userParm As SqlParameter = _sqlCommand.Parameters.Add("@Username", SqlDbType.NVarChar, 255)
Dim roleParm As SqlParameter = _sqlCommand.Parameters.Add("@Rolename", SqlDbType.NVarChar, 255)
_sqlCommand.Parameters.Add("@applicationName", SqlDbType.NVarChar, 255).Value = ApplicationName
Dim tran As SqlTransaction = Nothing
Try
_sqlConnection.Open()
tran = _sqlConnection.BeginTransaction
_sqlCommand.Transaction = tran
For Each username As String In usernames
For Each rolename As String In rolenames
userParm.Value = username
roleParm.Value = rolename
_sqlCommand.ExecuteNonQuery()
Next
Next
tran.Commit()
Catch e As SqlException
Try
tran.Rollback()
Catch
End Try
If WriteExceptionsToEventLog Then
WriteToEventLog(e, "RemoveUsersFromRoles")
Else
Throw e
End If
Finally
_sqlConnection.Close()
End Try
End Sub
' RoleProvider.RoleExists
Public Overrides Function RoleExists(ByVal rolename As String) As Boolean
Dim exists As Boolean = False
If pConnectionStringSettings Is Nothing OrElse pConnectionStringSettings.ConnectionString.Trim() = "" Then
pConnectionStringSettings = ConfigurationManager.ConnectionStrings("PRCConnectionString")
connectionString = pConnectionStringSettings.ConnectionString
End If
If ApplicationName Is Nothing Or ApplicationName = "" Then
ApplicationName = "PromoRegistration"
End If
Dim _sqlConnection As SqlConnection = New SqlConnection(connectionString)
Dim _sqlCommand As SqlCommand = New SqlCommand("Roles_RoleExists", _sqlConnection)
_sqlCommand.CommandType = CommandType.StoredProcedure
_sqlCommand.Parameters.Add("@Rolename", SqlDbType.NVarChar, 255).Value = rolename
_sqlCommand.Parameters.Add("@applicationName", SqlDbType.NVarChar, 255).Value = ApplicationName
Try
_sqlConnection.Open()
Dim numRecs As Integer = CType(_sqlCommand.ExecuteScalar(), Integer)
If numRecs > 0 Then
exists = True
End If
Catch e As SqlException
If WriteExceptionsToEventLog Then
WriteToEventLog(e, "RoleExists")
Else
Throw e
End If
Finally
_sqlConnection.Close()
End Try
Return exists
End Function
' RoleProvider.FindUsersInRole
Public Overrides Function FindUsersInRole(ByVal rolename As String, ByVal usernameToMatch As String) As String()
If pConnectionStringSettings Is Nothing OrElse pConnectionStringSettings.ConnectionString.Trim() = "" Then
pConnectionStringSettings = ConfigurationManager.ConnectionStrings("PRCConnectionString")
connectionString = pConnectionStringSettings.ConnectionString
End If
If ApplicationName Is Nothing Or ApplicationName = "" Then
ApplicationName = "PromoRegistration"
End If
Dim _sqlConnection As SqlConnection = New SqlConnection(connectionString)
Dim _sqlCommand As SqlCommand = New SqlCommand("Roles_FindUsersInRole", _sqlConnection)
_sqlCommand.CommandType = CommandType.StoredProcedure
_sqlCommand.Parameters.Add("@UsernameSearch", SqlDbType.NVarChar, 255).Value = usernameToMatch
_sqlCommand.Parameters.Add("@Rolename", SqlDbType.NVarChar, 255).Value = rolename
_sqlCommand.Parameters.Add("@applicationName", SqlDbType.NVarChar, 255).Value = ApplicationName
Dim tmpUserNames As String = ""
Dim _sqlDataReader As SqlDataReader = Nothing
Try
_sqlConnection.Open()
_sqlDataReader = _sqlCommand.ExecuteReader()
Do While _sqlDataReader.Read()
tmpUserNames &= _sqlDataReader.GetString(0) & ","
Loop
Catch e As SqlException
If WriteExceptionsToEventLog Then
WriteToEventLog(e, "FindUsersInRole")
Else
Throw e
End If
Finally
If Not _sqlDataReader Is Nothing Then _sqlDataReader.Close()
_sqlConnection.Close()
End Try
If tmpUserNames.Length > 0 Then
' Remove trailing comma.
tmpUserNames = tmpUserNames.Substring(0, tmpUserNames.Length - 1)
Return tmpUserNames.Split(CChar(","))
End If
Return New String() {}
End Function
'
' WriteToEventLog
' A helper function that writes exception detail to the event log. Exceptions
' are written to the event log as a security measure to aSub Private database
' details from being returned to the browser. If a method does not Return a status
' or boolean indicating the action succeeded or failed, a generic exception is also
' Thrown by the caller.
'
Private Sub WriteToEventLog(ByVal e As SqlException, ByVal action As String)
Dim log As EventLog = New EventLog()
log.Source = eventSource
log.Log = eventLog
Dim message As String = exceptionMessage & vbCrLf & vbCrLf
message &= "Action: " & action & vbCrLf & vbCrLf
message &= "Exception: " & e.ToString()
log.WriteEntry(message)
End Sub
End Class
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I have an admin folder that runs on its own app pool with its own web config etc... that folder has traditionaly (IIS 5-6) needed to be set up as an application. It appears that in IIS7 it does not need to be an application. Once I removed teh application for the admin folder every thing worked like a charm. I still have 32 bit dlls but setting the Enable 32 Bit applications to true in the advanced settings of the app pool of the root site allowed my 32bit code. Puting my Custom Membership providers in the GAC did not help.
Well, I hope this helps someone else.