Example #1
0
    public bool AddUserToGroup(string username, string groupname)
    {
        PermissionsManager permissionsManager = new PermissionsManager();
        if (Context.User.Identity.IsAuthenticated)
        {
            if (Website.Common.IsValidUser(username))
            {
                if (permissionsManager.GetGroupsByOwner(Context.User.Identity.Name).Contains(groupname))
                {
                    PermissionErrorCode ret = permissionsManager.AddUserToGroup(Context.User.Identity.Name, groupname, username);
                    if (ret == PermissionErrorCode.Ok)
                    {
                        permissionsManager.Dispose();
                        return true;
                    }

                }
            }
        }
        permissionsManager.Dispose();
        return false;
    }
Example #2
0
    public bool AddUserToGroup(string username, string groupname)
    {
        PermissionsManager permissionsManager = new PermissionsManager();

        if (Context.User.Identity.IsAuthenticated)
        {
            if (Website.Common.IsValidUser(username))
            {
                if (permissionsManager.GetGroupsByOwner(Context.User.Identity.Name).Contains(groupname))
                {
                    PermissionErrorCode ret = permissionsManager.AddUserToGroup(Context.User.Identity.Name, groupname, username);
                    if (ret == PermissionErrorCode.Ok)
                    {
                        permissionsManager.Dispose();
                        return(true);
                    }
                }
            }
        }
        permissionsManager.Dispose();
        return(false);
    }
Example #3
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void CreateUserWizardStep1_CreatedUser(object sender, EventArgs e)
    {
        // Create an empty Profile for the newly created user
        //ProfileCommon p = (ProfileCommon)ProfileCommon.Create(CreateUserWizard1.UserName, true);

        // Populate some Profile properties off of the create user wizard
        //p.FirstName = ((TextBox)CreateUserWizard1.CreateUserStep.Controls[0].FindControl("FirstName")).Text;
        //p.LastName = ((TextBox)CreateUserWizard1.CreateUserStep.Controls[0].FindControl("LastName")).Text;


        //load new membership user and set 'Comment' property to {FirstName}|{LastName}

        MembershipUser mu = String.IsNullOrEmpty(CreateUserWizard1.UserName) ? Membership.GetUser(CreateOpenIDWizard.UserName) : Membership.GetUser(CreateUserWizard1.UserName.Trim());

        //approved = false by default

        if (mu != null)
        {
            //set approved
            mu.IsApproved = Website.Config.MembershipUserApprovedByDefault;
            string targetRole = "Users";
            if (!Roles.IsUserInRole(mu.UserName, targetRole))
            {
                Roles.AddUserToRole(mu.UserName, targetRole);
            }

            //create user profile

            UserProfile p = null;

            string memGUID = mu.ProviderUserKey.ToString().Trim();
            string fName   = ((TextBox)CreateUserWizard1.CreateUserStep.Controls[0].FindControl("FirstName")).Text;
            string lName   = ((TextBox)CreateUserWizard1.CreateUserStep.Controls[0].FindControl("LastName")).Text;
            string email   = ((TextBox)CreateUserWizard1.CreateUserStep.Controls[0].FindControl("Email")).Text;

            try
            {
                p          = UserProfileDB.InsertUserProfile(memGUID, fName, lName, email, email, email);
                mu.Comment = p.FirstName.Trim() + "|" + p.LastName.Trim();

                Membership.UpdateUser(mu);
                Database.ConnString = Website.Config.PostgreSQLConnectionString;
                Database.DBType     = "MySQL";
                Database.DBPrefix   = "DMG";
                email = Functions.RepairString(email);
                string             password = Functions.Encrypt(Functions.RepairString(CreateUserWizard1.Password));
                PermissionsManager mgr      = new PermissionsManager();
                mgr.AddUserToGroup(System.Configuration.ConfigurationManager.AppSettings["DefaultAdminName"], vwarDAL.DefaultGroups.AllUsers, mu.UserName);
                if (Website.Config.SendEmailForNewRegistrations)
                {
                    Website.Mail.SendNewRegistrationNotificationEmail(mu);
                }
                mgr.Dispose();
                //Database.Write("INSERT INTO " + Database.DBPrefix + "_MEMBERS (MEMBER_USERNAME, MEMBER_PASSWORD, MEMBER_LEVEL, MEMBER_EMAIL, MEMBER_LOCATION, MEMBER_HOMEPAGE, MEMBER_SIGNATURE, MEMBER_SIGNATURE_SHOW, MEMBER_IM_AOL, MEMBER_IM_ICQ, MEMBER_IM_MSN, MEMBER_IM_YAHOO, MEMBER_POSTS, MEMBER_DATE_JOINED, MEMBER_DATE_LASTVISIT, MEMBER_TITLE, MEMBER_TITLE_ALLOWCUSTOM, MEMBER_TITLE_USECUSTOM, MEMBER_EMAIL_SHOW, MEMBER_IP_LAST, MEMBER_IP_ORIGINAL, MEMBER_REALNAME, MEMBER_OCCUPATION, MEMBER_SEX, MEMBER_AGE, MEMBER_BIRTHDAY, MEMBER_NOTES, MEMBER_FAVORITESITE, MEMBER_PHOTO, MEMBER_AVATAR, MEMBER_AVATAR_SHOW, MEMBER_AVATAR_ALLOWCUSTOM, MEMBER_AVATAR_USECUSTOM, MEMBER_AVATAR_CUSTOMLOADED, MEMBER_AVATAR_CUSTOMTYPE, MEMBER_VALIDATED, MEMBER_VALIDATION_STRING, MEMBER_RANKING) VALUES ('" + email + "','" + password + "', " + 1 + ", '" + email + "', ' ', ' ', ' ', 0, '', '', '', '', 0, " + Database.GetTimeStamp() + ", " + Database.GetTimeStamp() + ", '', 0, 0, 0, '', '', '', '', '', '', '', '', '', '', 1, 0 , 0, 0, 0, 'jpg', 1, '', 0)");
            }
            catch
            {
            }
        }

        // Save profile - must be done since we explicitly created it
        // p.Save();

        if (Website.Config.MembershipUserApprovedByDefault == false)
        {
            //not approved
            FormsAuthentication.SignOut();
            MultiView1.SetActiveView(ConfirmationView);
        }
        else
        {
            //approved
            FormsAuthentication.RedirectFromLoginPage(CreateUserWizard1.UserName, false);
            Website.Mail.SendRegistrationApprovalEmail(mu.Email);
        }
    }
    /// <summary>
    ///
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void CreateUserWizardStep1_CreatedUser(object sender, EventArgs e)
    {
        // Create an empty Profile for the newly created user
        //ProfileCommon p = (ProfileCommon)ProfileCommon.Create(CreateUserWizard1.UserName, true);

        // Populate some Profile properties off of the create user wizard
        //p.FirstName = ((TextBox)CreateUserWizard1.CreateUserStep.Controls[0].FindControl("FirstName")).Text;
        //p.LastName = ((TextBox)CreateUserWizard1.CreateUserStep.Controls[0].FindControl("LastName")).Text;


        //load new membership user and set 'Comment' property to {FirstName}|{LastName}

        MembershipUser mu = String.IsNullOrEmpty(CreateUserWizard1.UserName) ? Membership.GetUser(CreateOpenIDWizard.UserName) : Membership.GetUser(CreateUserWizard1.UserName.Trim());

        //approved = false by default

        if (mu != null)
        {
            //set approved
            mu.IsApproved = Website.Config.MembershipUserApprovedByDefault;
            string targetRole = "Users";
            if (!Roles.IsUserInRole(mu.UserName, targetRole))
            {
                Roles.AddUserToRole(mu.UserName, targetRole);
            }

            //create user profile

            UserProfile p = null;

            string memGUID = mu.ProviderUserKey.ToString().Trim();
            string fName   = ((TextBox)CreateUserWizard1.CreateUserStep.Controls[0].FindControl("FirstName")).Text;
            string lName   = ((TextBox)CreateUserWizard1.CreateUserStep.Controls[0].FindControl("LastName")).Text;
            string email   = ((TextBox)CreateUserWizard1.CreateUserStep.Controls[0].FindControl("Email")).Text;

            try
            {
                p          = UserProfileDB.InsertUserProfile(memGUID, fName, lName, email, email, email);
                mu.Comment = p.FirstName.Trim() + "|" + p.LastName.Trim();

                Membership.UpdateUser(mu);
                PermissionsManager mgr = new PermissionsManager();
                mgr.AddUserToGroup(System.Configuration.ConfigurationManager.AppSettings["DefaultAdminName"], vwarDAL.DefaultGroups.AllUsers, mu.UserName);
                if (Website.Config.SendEmailForNewRegistrations)
                {
                    Website.Mail.SendNewRegistrationNotificationEmail(mu);
                }
                mgr.Dispose();
            }
            catch
            {
            }
        }

        // Save profile - must be done since we explicitly created it
        // p.Save();

        if (Website.Config.MembershipUserApprovedByDefault == false)
        {
            //not approved
            FormsAuthentication.SignOut();
            MultiView1.SetActiveView(ConfirmationView);
        }
        else
        {
            //approved
            FormsAuthentication.RedirectFromLoginPage(CreateUserWizard1.UserName, false);
            Website.Mail.SendRegistrationApprovalEmail(mu.Email);
        }
    }
Example #5
0
    /// <summary>
    /// 
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void CreateUserWizardStep1_CreatedUser(object sender, EventArgs e)
    {
        // Create an empty Profile for the newly created user
        //ProfileCommon p = (ProfileCommon)ProfileCommon.Create(CreateUserWizard1.UserName, true);

        // Populate some Profile properties off of the create user wizard
        //p.FirstName = ((TextBox)CreateUserWizard1.CreateUserStep.Controls[0].FindControl("FirstName")).Text;
        //p.LastName = ((TextBox)CreateUserWizard1.CreateUserStep.Controls[0].FindControl("LastName")).Text;

        //load new membership user and set 'Comment' property to {FirstName}|{LastName}

        MembershipUser mu = String.IsNullOrEmpty(CreateUserWizard1.UserName) ? Membership.GetUser(CreateOpenIDWizard.UserName) : Membership.GetUser(CreateUserWizard1.UserName.Trim());

        //approved = false by default

        if (mu != null)
        {

            //set approved
            mu.IsApproved = Website.Config.MembershipUserApprovedByDefault;
            string targetRole = "Users";
            if (!Roles.IsUserInRole(mu.UserName, targetRole))
            {
                Roles.AddUserToRole(mu.UserName, targetRole);
            }

            //create user profile

            UserProfile p = null;

            string memGUID = mu.ProviderUserKey.ToString().Trim();
            string fName = ((TextBox)CreateUserWizard1.CreateUserStep.Controls[0].FindControl("FirstName")).Text;
            string lName = ((TextBox)CreateUserWizard1.CreateUserStep.Controls[0].FindControl("LastName")).Text;
            string email = ((TextBox)CreateUserWizard1.CreateUserStep.Controls[0].FindControl("Email")).Text;

            try
            {
                p = UserProfileDB.InsertUserProfile(memGUID, fName, lName, email, email, email);
                mu.Comment = p.FirstName.Trim() + "|" + p.LastName.Trim();

                Membership.UpdateUser(mu);
                Database.ConnString = Website.Config.PostgreSQLConnectionString;
                Database.DBType = "MySQL";
                Database.DBPrefix = "DMG";
                email = Functions.RepairString(email);
                string password = Functions.Encrypt(Functions.RepairString(CreateUserWizard1.Password));
                PermissionsManager mgr = new PermissionsManager();
                mgr.AddUserToGroup(System.Configuration.ConfigurationManager.AppSettings["DefaultAdminName"], vwarDAL.DefaultGroups.AllUsers, mu.UserName);
                if (Website.Config.SendEmailForNewRegistrations)
                {
                    Website.Mail.SendNewRegistrationNotificationEmail(mu);

                }
                mgr.Dispose();
                //Database.Write("INSERT INTO " + Database.DBPrefix + "_MEMBERS (MEMBER_USERNAME, MEMBER_PASSWORD, MEMBER_LEVEL, MEMBER_EMAIL, MEMBER_LOCATION, MEMBER_HOMEPAGE, MEMBER_SIGNATURE, MEMBER_SIGNATURE_SHOW, MEMBER_IM_AOL, MEMBER_IM_ICQ, MEMBER_IM_MSN, MEMBER_IM_YAHOO, MEMBER_POSTS, MEMBER_DATE_JOINED, MEMBER_DATE_LASTVISIT, MEMBER_TITLE, MEMBER_TITLE_ALLOWCUSTOM, MEMBER_TITLE_USECUSTOM, MEMBER_EMAIL_SHOW, MEMBER_IP_LAST, MEMBER_IP_ORIGINAL, MEMBER_REALNAME, MEMBER_OCCUPATION, MEMBER_SEX, MEMBER_AGE, MEMBER_BIRTHDAY, MEMBER_NOTES, MEMBER_FAVORITESITE, MEMBER_PHOTO, MEMBER_AVATAR, MEMBER_AVATAR_SHOW, MEMBER_AVATAR_ALLOWCUSTOM, MEMBER_AVATAR_USECUSTOM, MEMBER_AVATAR_CUSTOMLOADED, MEMBER_AVATAR_CUSTOMTYPE, MEMBER_VALIDATED, MEMBER_VALIDATION_STRING, MEMBER_RANKING) VALUES ('" + email + "','" + password + "', " + 1 + ", '" + email + "', ' ', ' ', ' ', 0, '', '', '', '', 0, " + Database.GetTimeStamp() + ", " + Database.GetTimeStamp() + ", '', 0, 0, 0, '', '', '', '', '', '', '', '', '', '', 1, 0 , 0, 0, 0, 'jpg', 1, '', 0)");
            }
            catch
            {

            }
        }

        // Save profile - must be done since we explicitly created it
        // p.Save();

        if (Website.Config.MembershipUserApprovedByDefault == false)
        {
            //not approved
            FormsAuthentication.SignOut();
            MultiView1.SetActiveView(ConfirmationView);

        }
        else
        {
            //approved
            FormsAuthentication.RedirectFromLoginPage(CreateUserWizard1.UserName, false);
            Website.Mail.SendRegistrationApprovalEmail(mu.Email);
        }
    }