How To Setup Initial User

According to Chris Blankenship's Starter accounts for Alternative Membership Provider,
I found there are cases when it is required to setup some initial (starter) user with ASP.NET XmlProviders.
Thus, I have added some additional attributes’ support to XmlMembershipProvider: initialRole, initialUser and initialPassword.
So, if you want when using ASP.NET XmlProviders to setup some initial user to be able to login first time and then later as logged user to do any changes required, you can add it by using those additional attributes.
For example, let’s say you want to add user - admin, password – admin, in role Administrators.
Here is how the XmlMembershipProvider config element will look like in your web.config file:

<membership defaultProvider="XmlMembershipProvider">
    <providers>
        <clear/>
        <add applicationName="Test" name="XmlMembershipProvider" type="Artem.Web.Security.XmlMembershipProvider"
             minRequiredPasswordLength="1" minRequiredNonalphanumericCharacters="0"
             requiresQuestionAndAnswer="false" requiresUniqueEmail="false" passwordFormat="Hashed"
             initialUser="admin" initialPassword="admin" initialRole="Administrators"/>
    </providers>
</membership>


This will create a user admin with password admin in role Administrators first time you use XmlMembershipProvider and if there is no Users.config file existing.


Happy coding ...

Any smart ideas and comments are welcome. Please do not hesitate to question me
See more about me and my works under ArtemBG | WebUtil.net

Last edited Dec 20, 2007 at 12:37 PM by velio, version 4

Comments

jlharcourt Jun 2, 2009 at 11:02 AM 
Hi Velio,
I am not using the 'initial user' part of my web.config, however I keep getting the default admin/admin user created. Have I missed something?
Regards