I'm trying to do the same thing and I can't get this code to compile. I copied the code above and converted it to C#. Some of the error message said that I needed a static reference to call some of the methods so I created objects like oRolesDB to call the static methods. Currently the error message is saying:
The type or namespace name 'DB' does not exist in the namespace 'YAF.Classes.Data'
Can anybody tell me what class or reference I need to complete this method? I'm also not sure why he's calling the foreach method because it looks like he's setting roles for the user that have already been set. Here's my broken code:
using System;
using System.Collections.Generic;
using System.Security.Permissions;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using YAF;
using YAF.Classes;
using YAF.Providers;
using YAF.Providers.Profile;
namespace YAF
{
public partial class LoadUsers : Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
private void CreateUser(String sApplicationName, String sUserName, String sPassword, String sEmail)
{
YAF.Classes.Data.DB oDataDB = new YAF.Classes.Data.DB();
YAF.Providers.Roles.DB oRolesDB = new YAF.Providers.Roles.DB();
YAF.Providers.Profile.DB oProfileDB = new YAF.Providers.Profile.DB();
YAF.Providers.Membership.DB oMembershipDB = new YAF.Providers.Membership.DB();
String sPasswordHashed = FormsAuthentication.HashPasswordForStoringInConfigFile(sPassword, "md5");
Object oUserKey = oProfileDB.GetProviderUserKey(sApplicationName, sUserName);
oRolesDB.AddUserToRole(sApplicationName, sUserName, "Registered");
oMembershipDB.CreateUser(sApplicationName, sUserName, sPasswordHashed, "", 0, sEmail, "", "", true, oUserKey);
String[] sUserRoles = Roles.GetRolesForUser(sUserName);
foreach (String sUserRole in sUserRoles)
{
oDataDB.user_setrole(1, oUserKey, sUserRole);
}
Object oUserLogin = oDataDB.user_aspnet(1, sUserName, sEmail, oUserKey, true);
String sUserIDFormatted = String.Format("{0};{1};{2}", oUserLogin, 1, sUserName);
FormsAuthentication.SetAuthCookie(sUserIDFormatted, true);
}
}
}
Edited by user
13 years ago |
Reason: Not specified