Thursday, December 18, 2008

Creating a DotNetNuke User Dynamically

Hey friends,
Working on DotNetNuke is really a great experience. I really love DotNetNuke. DotNetNuke is an aswer to great CMS solution for and there is no doubt about that. Recently, we decided to develop some modules which are really simple and don't required CMS facilities, so we decided to go for pur module in place of a dotnetnuke module.
Because we were using dotnetnuke providers for storing users and registering them, we have two questions regarding the new modules:
1) how to make existing dotnetnuke users use the module without new registration
2) how to make new registrations in module that can make the user use whole site. (i.e. new module's users can use all the site)

Well after some juggling, I got both the things working. To implement this, we implemented login and registration pages which uses dotnetnuke's apis for login and creating a new user respectively.

here are some code snippets which you can use to create a new DotNetNuke User:

DotNetNuke.Entities.Users.UserInfo uInfo = new UserInfo();
uInfo.Username = txtEmail.Text.ToString();
uInfo.Membership.Password = txtPassWord.Text.ToString();
uInfo.PortalID = 0;
uInfo.Email = txtEmail.Text.ToString();
DotNetNuke.Security.Membership.UserCreateStatus status = DotNetNuke.Entities.Users.UserController.CreateUser(ref uInfo);
if (status == DotNetNuke.Security.Membership.UserCreateStatus.Success)
//TODO User Created Successfully
//TODO Error Creating user s
lblError.Text = status.ToString();

No comments:

Post a Comment

Please add your valuable comments about this post if it helped you. Thanks