Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDNN Open Source...DNN Open Source...Provider and Extension ForumsProvider and Extension ForumsAuthenticationAuthenticationexample of custom providerexample of custom provider
Previous
 
Next
New Post
3/20/2009 8:49 AM
 

I've spent several days searching for some sample code of how to write your own authentication provider, without any success.  We are trying to use an external database of users for a separate application to validate access to DNN.  The DNN source code only has compiled dlls for the existing providers (AD, LiveID, etc), so that hasn't been much help to me.  If there is any sample code out there I can use to understand what I need to be doing, I would greatly appreciate any pointers to it.

Thanks

Pete

 
New Post
3/20/2009 11:42 AM
 

The source versions are all available for download on the DNN downloads page. If you look in the source .zip there will either be another .zip file inside it that contains all the necessary code behind or a file with a .resources extension that can be changed to .zip.

If you install the source version onto a development DNN install everything will be extracted from the .resources/.zip file.

 
New Post
3/23/2009 8:52 AM
 

I have expanded both the original .zip file for the 4.9.2 source, and the .resources file for the LiveID provider.  Both have only the front side code for the Login, logoff, and Settings pages and the manifest file.  The actual code to implement this provider appears to reside in a compiled dll, DotNetNuke.Authentication.LiveID.dll.  I understand that this may be proprietary code and not available for inspection, but if that is the case then it seems difficult if not impossible to see how this (or any of the other built-in) provider is built.

Thanks

Pete

 
New Post
3/23/2009 10:44 AM
 

Maybe I should expand on what I'm trying to do and how much (little) progress I've made.

We have a database that contains user information that we wish to have DNN use as primary authenticator, i.e., if the user doesn't exist in our database then deny login access to the portal.  If the user exists in our database then check the DNN users for the corresponding user.  If found, log the user in.  If not found, then create the user in DNN using the userid/password combination from our database..  I believe (but am not positive) that what I need to do to accomplish this is write a custom membership provider for our DNN version 4.09.02.

I downloaded a Wrox Blox entitled "Done in 60 Minutes:  Building a Custom DotNetNuke Membership Provider" by Antonio Chagoury (the 60 minutes part may be a bit optimistic).  I followed the instructions to create a custom membership provider by copying the AspNetMembership project and modifying the namespaces and class names, and adding the project to our website project.  After some tweaking, I got it to build with no errors. 

I first tried to just modify the web.config per the article's instructions to add my provider as the default membership provider as shown below. (my provider is the IDXMembershipProvider).

    <members defaultProvider="IDXMembershipProvider">
        <providers>
                <clear/>
                  <add name="AspNetMembershipProvider" type="DotNetNuke.Security.Membership.AspNetMembershipProvider, DotNetNuke.Provider.AspNetProvider" providerPath="~\Providers\MembershipProviders\AspNetMembershipProvider\"/>
            <add name="IDXMembershipProvider" type="DotNetNuke.Security.Membership.IDXMembershipProvider, DotNetNuke.Provider.IDXNetProvider, Culture=neutral" providerPath="~\Providers\MembershipProviders\IDXMembershipProvider\"/>
          </providers>
    </members>
 

Doing this caused the application to throw an error on startup:

[ArgumentNullException: Value cannot be null.
Parameter name: type]
   System.Activator.CreateInstance(Type type, Boolean nonPublic) +7467190
   DotNetNuke.Framework.Reflection.CreateObject(String ObjectProviderType, String ObjectProviderName, String ObjectNamespace, String ObjectAssemblyName, Boolean UseCache) +584
   DotNetNuke.Framework.Reflection.CreateObject(String ObjectProviderType, Boolean UseCache) +26
   DotNetNuke.Security.Membership.MembershipProvider.CreateProvider() +31
   DotNetNuke.Security.Membership.MembershipProvider..cctor() +13

[TypeInitializationException: The type initializer for 'DotNetNuke.Security.Membership.MembershipProvider' threw an exception.]
   DotNetNuke.Security.Membership.MembershipProvider.Instance() +0
   DotNetNuke.Entities.Users.UserController..cctor() +5

[TypeInitializationException: The type initializer for 'DotNetNuke.Entities.Users.UserController' threw an exception.]
   DotNetNuke.Entities.Users.UserController.GetUserCountByPortal(Int32 portalId) +0
   DotNetNuke.Entities.Portals.PortalInfo.get_Users() +20
   DotNetNuke.Entities.Portals.PortalSettings.GetPortalSettings(Int32 TabId, PortalAliasInfo objPortalAliasInfo) +1727
   DotNetNuke.Entities.Portals.PortalSettings..ctor(Int32 tabId, PortalAliasInfo objPortalAliasInfo) +76
   DotNetNuke.HttpModules.UrlRewriteModule.OnBeginRequest(Object s, EventArgs e) +3391
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +68
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75

There were some forum posts on this error, but all the posts were on previous versions of DNN, and their suggestions didn't help.  I tried adding my compiled dlls as references to the web project, with no luck.

I then used the AspNetMembershipProvider.dnn manifest as a template to create a manifest file for my provider, and zipped it up.  I then went into Host Settings/Authentication Settings, pointed to my .zip file, and installed it with no errors.  It did NOT show up under the list of authentication providers (perhaps because it's not an authentication provider, but I don't know of any way to "install" a membership provider).  If I then set my provider back to the default, it throws the same exception as above.

Obviously I am missing some fundamental step(s) in accomplishing this task, and have been unable to find anything but the abovementioned Wrox Blox detailing the process for creating and installing your own membership provider.  I am new to DNN, so I expect the problem exists between keyboard and chair.  Any help will be gratefully accepted.

 

Thanks

Pete

 
New Post
3/24/2009 12:25 AM
 

psaunder wrote

I have expanded both the original .zip file for the 4.9.2 source, and the .resources file for the LiveID provider.  Both have only the front side code for the Login, logoff, and Settings pages and the manifest file.  The actual code to implement this provider appears to reside in a compiled dll, DotNetNuke.Authentication.LiveID.dll.  I understand that this may be proprietary code and not available for inspection, but if that is the case then it seems difficult if not impossible to see how this (or any of the other built-in) provider is built.

Thanks

Pete

I'm looking at the LiveID Source Files.resources (renamed the extension to .zip) and it's got all the .cs files in there.

I only very briefly looked at Antonio's provider example. I've got it on a computer at work so I'll try to take a look at it tomorrow to see if I can help you progress further.

 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Provider and Extension ForumsProvider and Extension ForumsAuthenticationAuthenticationexample of custom providerexample of custom provider


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out