Saturday, May 24, 2008

Retrieve Asp .net Form Based Authentication Data Base Connection String Name of a MOSS or Windows SharePoint Services 3.0 Web Application

Introduction:
This post show how to retrieve the Asp .Net Form Based Authentication DataBase Connection String Name of a MOSS or Windows SharePoint Services 3.0 Web Application by server side C# programming.
This is the following of the previous post : How to retrieve the Membership provider name . Knowing the name of the membership provider you can retrieve the Asp .Net Form Based Authentication DataBase Connection String Name in the web.config file of your web application doing this :
Code Sample:

        string connexionStringName = string.Empty;

        //we retrieve the connection string used for the form authentication based membershipprovider

        System.Web.Configuration.MembershipSection mysection = (System.Web.Configuration.MembershipSection)ConfigurationManager.GetSection(@"system.web/membership");

 

        for (int j = 0; j < mysection.Providers.Count; j++)

        {

            if (mysection.Providers[j].Name == memberShipProviderName)

            {

                connexionStringName = mysection.Providers[j].ElementInformation.Properties["connectionStringName"].Value.ToString();

            }

        }

1 comment:

sarah lee said...

I really enjoyed reading your article. I found this as an informative and interesting post, so i think it is very useful and knowledgeable. I would like to thank you for the effort you have made in writing this article.


edupdf.org