Small width layout Medium width layout Maximum width layout Small text Medium text Large text
     Search
Downloads Downloads Directory Directory Forums Forums Forge Forge Blogs Blogs        Marketplace Marketplace Careers Program Careers
Community › Forums Register  |  

PortalWebHosting
  Ads  
r2i.ntegrated
 


  Sponsors  

Meet Our Sponsors

eUKhost.com is commited to offer exceptional UK Windows Web Hosting solutions with quality 24x7 technical support.Our plans support ASP.Net, ASP, ASP.NET Ajax extensions, XML, MSSQL, MySQL, PHP,DNN, multiple domains and Shared SSL as standard.
SmarterTools
The Official Microsoft ASP.NET Website
Portal Webhosting - Hosting For Developers
Red-Gate Software
MaximumASP
 


DotNetNuke Forums
 
  Forum  DotNetNuke® Pro...  Authentication ...  Documentation?
Previous Previous
 
Next Next
New Post 2/28/2008 5:26 PM
Unresolved
User is offline Felix Burkhard
20 posts
10th Ranked


Documentation? 

Hi All

I need to write a provider that authenticates users against another SQL DB. I assume after successful authentication you need to create the user in the DNN DB.

Is there any documentation on how to write a new authentication provider, eg what API or interfaces one must make available in the provider? I appreciate the availability of the live id source code, but I think that code is NOT a good documentation. What is needed is some overview of the architecture and guidelines on how to write your own.

Felix Burkhard

 

 

 
New Post 2/29/2008 7:44 AM
User is offline Mike Horton
3163 posts
dnn.gmss.org
4th Ranked






Re: Documentation? 

Hi Felix

There isn't a white-paper on writing a provider and it's something that does need to be done (I just don't know when I'll get to it). However you've got gist of it (authenticate then create/login the user in the DNN DB). Writing a provider isn't all that different than writing any module until it comes to the login/settings/logout pages where you're overriding the core procedures.

 
New Post 3/4/2008 12:35 PM
User is offline Ryan Hamner
3 posts
10th Ranked


Re: Documentation? 

All I have is an example and this isn't exactly what you're asking for but I had to do something similar. What I did was left DDN as the source for users and roles and synchronized them with my other system. To do this just inherit the DNN providers and only override the methods you need. It works great if you put a checks in place like when adding a user to a role check the existence of both the user and the role in the other system first and create them if they don’t exist. Also, note that in the code below I was calling web services with no support for transactions. If your making database calls or something else that supports transactions you’d probably want to make your call to the other system first and commit or rollback based on whether the DDN call succeeds.

Membership Provider:

 
using System;
using System.Web;
using DotNetNuke.Common;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Entities.Portals;
using DotNetNuke.Entities.Users;
using DotNetNuke.Entities.Profile;
using DotNetNuke.Framework.Providers;
using DotNetNuke.Security.Roles;
using DotNetNuke.Services.Exceptions;
using DotNetNuke.Security.Membership;

namespace BMT.Security.Membership
{
    public class BmtAspNetProvider : DotNetNuke.Security.Membership.AspNetMembershipProvider
    {


        public override Boolean ChangePassword(UserInfo user, String oldPassword, String newPassword)
        {

            DotNetNuke.Entities.Users.UserInfo curUserInfo;

            curUserInfo = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo();


            HttpContext Context = HttpContext.Current;

            Boolean retVal;

            //change password first in dnn to make sure it's valid
            retVal = base.ChangePassword(user, oldPassword, newPassword);

            if (retVal == true)
            {
                try
                {

                    //your code here

                }
                catch (Exception e)
                {

                    //your code here

                }
            }

            return retVal;

        }

        public override UserCreateStatus CreateUser(ref UserInfo user)
        {

            DotNetNuke.Entities.Users.UserInfo curUserInfo;
            curUserInfo = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo();

            HttpContext Context = HttpContext.Current;

            UserCreateStatus uStatus = base.CreateUser(ref user);


            if (uStatus == UserCreateStatus.Success)
            {
                try
                {

                    //your code here

                }
                catch (Exception e)
                {

                    //your code here

                }

            }

            return uStatus;

        }

        public override void UpdateUser(UserInfo user)
        {

            DotNetNuke.Entities.Users.UserInfo curUserInfo;
            curUserInfo = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo();

         
            HttpContext Context = HttpContext.Current;

            try
            {

                //your code here

            }
            catch (Exception e)
            {

                //your code here

            }

            base.UpdateUser(user);

        }

        public override string ResetPassword(UserInfo user, string passwordAnswer)
        {

            DotNetNuke.Entities.Users.UserInfo curUserInfo;
            curUserInfo = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo();

            HttpContext Context = HttpContext.Current;

            String newPassword;
            newPassword = base.ResetPassword(user, passwordAnswer);

            try
            {

                //your code here

            }
            catch (Exception e)
            {

                //your code here

            }

            return newPassword;

        }
       
        public override bool DeleteUser(UserInfo user)
        {

            try
            {

                //your code here

            }
            catch (Exception e)
            {

                //your code here

            }

            return base.DeleteUser(user);
        }
       
    }
}

 

Role Provider:

using System;
using System.Web;
using DotNetNuke.Common;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Entities.Portals;
using DotNetNuke.Entities.Users;
using DotNetNuke.Entities.Profile;
using DotNetNuke.Framework.Providers;
using DotNetNuke.Security.Roles;
using DotNetNuke.Services.Exceptions;
using DotNetNuke.Security.Membership;

namespace BMT.Security.Membership
{
    public class BMTRoleProvider : DotNetNuke.Security.Membership.DNNRoleProvider
    {

        public override bool CreateRole(int portalId, ref RoleInfo role)
        {

            DotNetNuke.Entities.Users.UserInfo curUserInfo;
            curUserInfo = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo();

            HttpContext Context = HttpContext.Current;

            Boolean retVal = base.CreateRole(portalId, ref role);

            if (retVal == true)
            {
                try
                {

                    //your code here

                }
                catch (Exception e)
                {

                    //your code here

                }
            }

            return retVal;
        }

        public override void UpdateRole(RoleInfo role)
        {
            DotNetNuke.Entities.Users.UserInfo curUserInfo;
            curUserInfo = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo();

            HttpContext Context = HttpContext.Current;

            //role.RoleName is null
            DotNetNuke.Security.Roles.RoleController rc = new DotNetNuke.Security.Roles.RoleController();
            DotNetNuke.Security.Roles.RoleInfo newRoleInfo;
            newRoleInfo = rc.GetRole(role.RoleID, role.PortalID);

            try
            {

                //your code here

            }
            catch (Exception e)
            {

                //your code here
            }

            base.UpdateRole(role);
        }

        public override bool AddUserToRole(int portalId, UserInfo user, UserRoleInfo userRole)
        {

            DotNetNuke.Entities.Users.UserInfo curUserInfo;
            curUserInfo = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo();

            //rolename in UserRoleInfo is null
            DotNetNuke.Security.Roles.RoleController rc = new DotNetNuke.Security.Roles.RoleController();
            DotNetNuke.Security.Roles.RoleInfo newRoleInfo;
            newRoleInfo = rc.GetRole(userRole.RoleID, userRole.PortalID);


            HttpContext Context = HttpContext.Current;

            Boolean retVal = base.AddUserToRole(portalId, user, userRole);

            if (retVal == true)
            {
                try
                {

                    //your code here

                }
                catch (Exception e)
                {

                    //your code here
                }
            }

            return retVal;
        }

        public override void UpdateUserRole(UserRoleInfo userRole)
        {

            DotNetNuke.Entities.Users.UserInfo curUserInfo;
            curUserInfo = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo();

            DotNetNuke.Entities.Users.UserInfo _UserInfo;
            _UserInfo = DotNetNuke.Entities.Users.UserController.GetUser(userRole.PortalID, userRole.UserID, false);

            HttpContext Context = HttpContext.Current;

            try
            {


                //your code here

            }
            catch (Exception e)
            {

                //your code here
            }

            base.UpdateUserRole(userRole);

        }

        public override void RemoveUserFromRole(int portalId, UserInfo user, UserRoleInfo userRole)
        {

            DotNetNuke.Entities.Users.UserInfo curUserInfo;
            curUserInfo = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo();

            HttpContext Context = HttpContext.Current;

            try
            {

                //your code here

            }
            catch (Exception e)
            {

                //your code here

            }

            base.RemoveUserFromRole(portalId, user, userRole);
        }

        public override void DeleteRole(int portalId, ref RoleInfo role)
        {
            try
            {

                //your code here

            }
            catch (Exception e)
            {

                //your code here

            }

            base.DeleteRole(portalId, ref role);
        }

    }

}

 

 
New Post 9/8/2008 3:27 PM
User is offline Matthew Cushing
53 posts
10th Ranked


Re: Documentation? 

I'm trying to find out a list of Roles for the current User that's logged in.

I'm trying to use your code above, but it doesn't give me what I'm looking for.  Any ideas?

 
Previous Previous
 
Next Next
  Forum  DotNetNuke® Pro...  Authentication ...  Documentation?
 


Forum Policy

These Discussion Forums are dedicated to the discussion of the DotNetNuke Web Application Framework.

For the benefit of the community and to protect the integrity of the project, 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 DotNetNuke.
2. Discussion or promotion of DotNetNuke product releases under a different brand name are strictly prohibited.
3. No Flaming or Trolling.
4. No Profanity, Racism, or Prejudice.
5. Site Moderators have the final word on approving/removing a thread or post or comment.
6. English language posting only, please.

 


$7.16/mo - Powerful DotNetNuke / DNN Hosting
Powerful DotNetNuke / DNN Hosting on Windows 2008 and 2003 servers, starting at under $8/mo with FREE SQL 2008 on certain plans and FREE SQL 2005 on all plans with FREE Installation and expert support.
www.re-invent.com
ASP.NET Web Hosting for $3.95
3 Month FREE ASP.NET Hosting! FREE Setup! DNN Support! FREE Domain Name! FREE Components! Host multiple websites on 1 plan! 30 Days Money Back Guarantee!
www.dailyrazor.com
Cestus Websites
DotNetNuke websites en services in Nederland. Cestus Websites levert websites, projectmanagent, skins, modules, training en gespecialiseerde hosting op basis van het CMS DotNetNuke.
www.dotnetnuke-websites.nl

DotNetNuke Corporation   Terms Of Use  Privacy Statement
DotNetNuke®, DNN®, and the DotNetNuke logo are trademarks of DotNetNuke Corporation
Hosted by MaximumASP