Click here to Skip to main content
15,029,010 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how to change the membership section of web config file? the membership section of my web config file is as follows

<pre lang="xml"><membership defaultprovider="i">
<providers>
<add name="i" type="Microsoft.SharePoint.Administration.Claims.SPClaimsAuthMembershipProvider, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
<add connectionstringname="SQLConnectionString" passwordattemptwindow="5" enablepasswordretrieval="false" enablepasswordreset="false" requiresquestionandanswer="false" applicationname="/" requiresuniqueemail="false" minrequiredpasswordlength="6" minrequirednonalphanumericcharacters="0" description="Stores and Retrieves membership data from SQL Server" name="SQL-MembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</providers>
</membership></pre>

here i wanna change the values for example the value- passwordAttemptWindow="5"

I have added below code to solve this,
var config=WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);
var section = (MembershipSection)config.GetSection("system.web/membership");
var defaultProvider = section.DefaultProvider;
var providerSettings = section.Providers[defaultProvider];
providerSettings.Parameters.Set("maxInvalidPasswordAttempts", "7");
providerSettings.Parameters.Set("passwordAttemptWindow", "7");
config.Save();
when executed it just added the properties to the section, not edited.
now the web config file is like below
<providers>
<add maxinvalidpasswordattempts="7" passwordattemptwindow="7">
name="i" type="Microsoft.SharePoint.Administration.Claims.SPClaimsAuthMembershipProvider, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" /&gt;
<add connectionstringname="SQLConnectionString" passwordattemptwindow="5">
enablePasswordRetrieval="false" enablePasswordReset="false"
requiresQuestionAndAnswer="false" applicationName="/" requiresUniqueEmail="false"
minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0"
description="Stores and Retrieves membership data from SQL Server"
name="SQL-MembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /&gt;
</add></add></providers>

how can i edit the values?
Posted
Updated 24-May-11 3:00am
v4

1 solution

here i wanna change the values for example the value- passwordAttemptWindow="5"
Go ahead and change it! What is stopping you? It's a simple XML file and you can set the desired values of the different attributes even by opening it in a textpad.
   
Comments
fjdiewornncalwe 24-May-11 8:49am
   
+5. Of course.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900