RE: Get data from Local Web.config not machine.config

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Solution.

The problem is the application Inheritance. The app get information from the
machine.config.
All membership providers in machine.config are added to the membership
providers in the local web.config.

To solve this use the <clear/> tag in the Membership section this will clear
all inherited membership providers for the app.

<membership >
<providers >
<clear />
<add name="MemberProv1" applicationName="/myapp"
connectionStringName="MemConnection1" requiresQuestionAndAnswer="false"
minRequiredPasswordLength="3" requiresUniqueEmail="false"
minRequiredNonalphanumericCharacters="0" passwordStrengthRegularExpression=""
type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
<add name="ADProvider1"
attributeMapUsername="sAMAccountName"
connectionStringName="ADConnectionString1" connectionUsername="rpaul"
connectionPassword="ajdoivmejr" enableSearchMethods="true"
type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</providers>
</membership>


Then when I use:
Dim MemSection As New MembershipSection
Dim RoleSection As New RoleManagerSection
MemSection = rootWebConfig1.GetSection("system.web/membership")
RoleSection = rootWebConfig1.GetSection("system.web/roleManager")

RoleSection.Providers(0).Name or
Membership.Providers(0).Name

I will only get RoleProviders or Membership providers from my web.config

I will not use Providers from the machine config. in the app.

Thank you,



--
Jerry


"Allen Chen [MSFT]" wrote:

Hi Jerry,

I really understand you may feel inconvenience that we cannot get
AspNetSqlMembershipProvider in an easier way. You're welcome to submit a
feedback here:

https://connect.microsoft.com/VisualStudio/Feedback?wa=wsignin1.0

Our development team will take into consideration all suggestions and
feedback for future releases and updates. With efforts from customers, we
continue to make our products better.


Regards,
Allen Chen
Microsoft Online Support

--------------------
| Thread-Topic: Get data from Local Web.config not machine.config
| thread-index: Ack1Fa+36aDtinreT0GwbKzBZF9JKw==
| X-WBNR-Posting-Host: 207.46.192.207
| From: =?Utf-8?B?SmVycnkgQw==?= <jerryed@xxxxxxxxxxxxx>
| References: <97962A86-0671-408D-B114-1C2B2A9FC997@xxxxxxxxxxxxx>
<EQciCmLNJHA.1656@xxxxxxxxxxxxxxxxxxxxxx>
| Subject: RE: Get data from Local Web.config not machine.config
| Date: Thu, 23 Oct 2008 06:46:01 -0700
| Lines: 133
| Message-ID: <1F6C86E9-D59C-44D9-A80A-9683CD14E2AC@xxxxxxxxxxxxx>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.3119
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| Path: TK2MSFTNGHUB02.phx.gbl
| Xref: TK2MSFTNGHUB02.phx.gbl
microsoft.public.dotnet.framework.aspnet:78471
| NNTP-Posting-Host: tk2msftibfm01.phx.gbl 10.40.244.149
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Allen,
|
| Thank you for your reply,
|
| I was hopping that the Configuration objects would have some funcions
that
| only read the sections in the local config file only and not the machine
| config. The Membership and role sections may contain passwords so I
planned
| to encript them in some installations. This would make using the xml
reader
| and stream reader more complax. If I cannot get a list of Membership and
Role
| providers only from the local config file I can put a list of the
providers
| in the appSettings section. This makes the application setup more complex
but
| may be necessary.
|
| Thank you
| --
| Jerry
|
|
| "Allen Chen [MSFT]" wrote:
|
| > Hi Jerry,
| >
| > We can read the web.config directly. Please refer to my reply in this
post:
| >
| >
http://thesource.ofallevil.com/communities/newsgroups/list/en-us/default.asp
| >
x?dg=microsoft.public.dotnet.framework.aspnet&tid=0e140c7e-d85d-47bc-bcba-52
| >
35731b9edb&cat=en_us_10ca9291-071d-4a5d-ba07-3a2422fddf6a&lang=en&cr=us&sloc
| > =&p=1
| >
| > If it's not what you need please let me know and clarify your
requirement.
| >
| > Regards,
| > Allen Chen
| > Microsoft Online Support
| >
| > Delighting our customers is our #1 priority. We welcome your comments
and
| > suggestions about how we can
| >
| > improve the support we provide to you. Please feel free to let my
manager
| > know what you think of the
| >
| > level of service provided. You can send feedback directly to my manager
at:
| > msdnmg@xxxxxxxxxxxxxx
| >
| > ==================================================
| > Get notification to my posts through email? Please refer to
| > http://msdn.microsoft.com/en-
| >
| > us/subscriptions/aa948868.aspx#notifications.
| >
| > Note: The MSDN Managed Newsgroup support offering is for non-urgent
issues
| > where an initial response
| >
| > from the community or a Microsoft Support
| > Engineer within 1 business day is acceptable. Please note that each
follow
| > up response may take
| >
| > approximately 2 business days as the support
| > professional working with you may need further investigation to reach
the
| > most efficient resolution. The
| >
| > offering is not appropriate for situations
| > that require urgent, real-time or phone-based interactions or complex
| > project analysis and dump analysis
| >
| > issues. Issues of this nature are best handled working with a dedicated
| > Microsoft Support Engineer by
| >
| > contacting Microsoft Customer Support Services (CSS) at
| >
| >
http://support.microsoft.com/select/default.aspx?target=assistance&ln=en-us.
| > ==================================================
| > This posting is provided "AS IS" with no warranties, and confers no
rights.
| > --------------------
| > | Thread-Topic: Get data from Local Web.config not machine.config
| > | thread-index: Ack0dMPG5k4uZE29T5SP1nO/sd0qAQ==
| > | X-WBNR-Posting-Host: 65.55.21.8
| > | From: =?Utf-8?B?SmVycnkgQw==?= <jerryed@xxxxxxxxxxxxx>
| > | Subject: Get data from Local Web.config not machine.config
| > | Date: Wed, 22 Oct 2008 11:34:06 -0700
| > | Lines: 29
| > | Message-ID: <97962A86-0671-408D-B114-1C2B2A9FC997@xxxxxxxxxxxxx>
| > | MIME-Version: 1.0
| > | Content-Type: text/plain;
| > | charset="Utf-8"
| > | Content-Transfer-Encoding: 7bit
| > | X-Newsreader: Microsoft CDO for Windows 2000
| > | Content-Class: urn:content-classes:message
| > | Importance: normal
| > | Priority: normal
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.3119
| > | Newsgroups: microsoft.public.dotnet.framework.aspnet
| > | Path: TK2MSFTNGHUB02.phx.gbl
| > | Xref: TK2MSFTNGHUB02.phx.gbl
| > microsoft.public.dotnet.framework.aspnet:78389
| > | NNTP-Posting-Host: tk2msftibfm01.phx.gbl 10.40.244.149
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| > |
| > | I have a app that uses several membership/role providers. I can list
| > these
| > | Providers with the code:
| > | Dim rootWebConfig1 As Configuration
| > | rootWebConfig1 =
| > | WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath)
| > | Dim section As New MembershipSection
| > | section = rootWebConfig1.GetSection("system.web/membership")
| > |
| > |
| > |
| > | Using the Immediate Window :
| > |
| > | ? section.Providers(0).Name
| > | "AspNetSqlMembershipProvider"
| > | ? section.Providers(1).Name
| > | "MemberProv1"
| > | ? section.Providers(2).Name
| > | "ADProvider1"
| > |
| > | As you can see I can list the providers but the Provider
| > | AspNetSqlMembershipProvider" is in the machine.config I do not have
| > control
| > | over the machine config at all my sites so I want to get the
Providers
| > only
| > | from the web.config in my application.
| > |
| > | How do I do this.
| > |
| > | Thank you
| > | --
| > | Jerry
| > |
| >
| >
|


.



Relevant Pages

  • RE: WebConfigurationManager.GetSection in Medium Trust
    ... Microsoft Online Support ... where an initial response from the community or a Microsoft Support ... | Thread-Topic: WebConfigurationManager.GetSection in Medium Trust ... | Is it possible for a medium trust web application to read the Membership ...
    (microsoft.public.dotnet.framework.aspnet)
  • RE: ASP.net Web application admin... security
    ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.dotnet.framework.aspnet)
  • RE: Multiple Membership providers and AddUserToRole
    ... We want to ONE roleprovider and multiple membershipproviders. ... Just like the membership provider, ... Microsoft MSDN Online Support Lead ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • RE: WCF Service on public IIS and SqlMembershipProvider/SqlRoleProvider
    ... you can use ASP.NET membership and RoleManager ... provider for your WCF service's authentication and authorization. ... #Use ASP.NET Membership and Role Providers in Windows Communication ... Microsoft MSDN Online Support Lead ...
    (microsoft.public.dotnet.framework.aspnet.webservices)
  • RE: custom sqlmembership provider
    ... To configure the application to use the custom Membership Service, ... The Membership section can have multiple providers listed ... Microsoft Online Support ...
    (microsoft.public.dotnet.framework.aspnet.security)