Calling all developers! We invite you to provide your input on Feature Experimentation by completing this brief survey.
Calling all developers! We invite you to provide your input on Feature Experimentation by completing this brief survey.
Here is a script I use:
<script runat="server">
private void Page_Init(object sender, System.EventArgs e)
{
string username = "MyAdminUser";
string password = "MyAdminPassword";
string[] groupNames = new string[]{ "Administrators", "WebAdmins" };
EPiServer.DataAbstraction.UserSid admin = EPiServer.DataAbstraction.UserSid.Load(username);
if (admin == null)
{
admin = new EPiServer.DataAbstraction.UserSid(EPiServer.Security.SecurityIdentityType.ExtranetUser);
admin.Name = username;
admin.Password = password;
admin.Active = true;
admin.Save();
admin = EPiServer.DataAbstraction.UserSid.Load(username);
foreach (string groupName in groupNames)
{
EPiServer.DataAbstraction.GroupSid group = EPiServer.DataAbstraction.GroupSid.Load(groupName);
if (group != null)
{
admin.MemberOfGroups.Add(group);
}
else
{
throw new System.Exception("Failed to load group " + groupName + "!");
}
}
admin.SaveGroupMembership();
}
else
{
throw new System.Exception("User " + username + " already exists!");
}
}
</script>
Another approach:
Change the authentication mode to use windows authentication instead of forms auth. (This is done in web.config)
Then logon to the webserver(physically) with a user that is a member of the local administrators group open the 4.60 website and go into admin mode. Now you can create youself an admin account.
Switch back to forms authentication.
Regards,
Morten
An addition to the post right above this - there should be no need to change the authentication mode to Windows. All administrator accounts on the computer the web server is running on have administrator rights in EPiServer 4.x as well, even if Forms authentication is used.
Alternatively, edit your web.config file and change in <location path="admin"> from <allow roles="WebAdmins, Administrators" /> to <allow roles="*" /> - then enter admin mode and create a user which has admin rights, then change back in web.config again.
Tryed the code Magnus posted and it worked great!
I dident try the solutions provided after that since I allready got it to work but they sound like good problem solvers also.
All that remains is for you guys to start beting on how many "Newbie question" threads I posted before I got "ECD" ;)
Have a nice day everybody and thank you everyone who contributed!
Ok I manged to mess up that last post, deleteing then trying to edit things back was not a good idea. Anyways:
Tryed the code Magnus posted and it worked great!
I dident try the solutions provided after that since I allready got it to work but they sound like good problem solvers also.
All that remains is for you guys to start beting on how many "Newbie question" threads I posted before I get "ECD" ;)
Have a nice day everybody and thank you everyone who contributed!
As concluded in an other post recently, developers running a Swedish (or other) version of windows where the local administrators group is not called "Administrators" ("Administratörer" in Swedish version) have to at least add the corresponding role to the <allow roles=... of their <location path=... for admin and edit to be able to log in with a local windows administrators account.
Hello everyone, I hope your all having a nice day!
Ive been given a copy of real episerver 4.60 website for training purposes.
Everything is up and running and seems to be working fine however I have one problem, I dont have any admin login.
I have been adviced to create a user from code like this: http://sdk.episerver.com/library/cms5/html/M_EPiServer_Security_WindowsMembershipProvider_CreateUser.htm
The problem is this SDK is for episerver 5 and the site is running 4.60. WindowsAuthenticationProvider dont seem to have this method in 4.60.
I searched around and found this http://world.episerver.com/en/FAQ/Items/How-do-I-create-and-manage-Users/ .
This compiles and runs but I cant login using the user I just created and I am not sure how to set the user I created to be admin.
Any Ideas?
Kind Regards
Pontus