locked
Adding users to web application policy RRS feed

  • Question

  • Hello,
    I am new to MOSS 2007. I am working on Form Based Authentication. It seems  that we need to add the database users to the web application policy from Central admin->Application Security ->Web Application Policies ->Users  as  a last step in Forms Based Authentication. I would like to give the sign up option for users from the web site. In that Case, the users will be created automatically  from the UI ...  

    Can some body suggest me the best way to add these new users to the web application policy with out using sharepoint central admin browser..( Is there any way to automatize this process?)
    Thanks in advance,
    Vasavi. 
    Thursday, August 27, 2009 8:19 PM

Answers

  • Hi,
    I believe, It would be wiser to use single credentials to connect with database and not add all registered users to web application policy.
    Hope i have understood your query right.
    Abdul Khalid.
    Friday, August 28, 2009 5:03 AM
  • Hi,

         You can use SPWEb.EnsureUser method

    Regards,
    Milan
    Friday, August 28, 2009 7:09 AM
  • Hi,

    Check this article:
    Configuring Multiple Authentication Providers for SharePoint 2007
    http://blogs.msdn.com/sharepoint/archive/2006/08/16/configuring-multiple-authentication-providers-for-sharepoint-2007.aspx
    And note:
    "Use Policies sparingly: The concept described above for adding a user or group via the web application Policy should only be used to provide a way for an FBA administrator to access the site.  Policies are very coarsely grained compared to the fine grain permissions that can be configured and granted within individual sites, lists and items.  Once you’ve added your site administrator via Policy, all other users and groups should be added from within the site itself"

    If your question, how to make existing ASP.NET 2.0 membership users to actual SharePoint users, then you can follow Milan's recommendation:

    using (SPSite site = new SPSite(http://yoursite))
    {
      using (SPWeb web = site.OpenWeb())
      {
        MembershipUserCollection membershipCol = Membership.GetAllUsers();
        foreach (MembershipUser member in membershipCol)
        {
          web.EnsureUser(mu.UserName);
        }
      }
    }

    If you have to create new users, you can do that using the ASP.NET 2.0 Memebership and Role provider API, for example add user with Membership.CreateUser method (http://msdn.microsoft.com/en-us/library/system.web.security.membership.createuser.aspx).

    Peter

    Friday, August 28, 2009 7:59 AM

All replies

  • Hi,
    I believe, It would be wiser to use single credentials to connect with database and not add all registered users to web application policy.
    Hope i have understood your query right.
    Abdul Khalid.
    Friday, August 28, 2009 5:03 AM
  • Hi,

         You can use SPWEb.EnsureUser method

    Regards,
    Milan
    Friday, August 28, 2009 7:09 AM
  • Hi,

    Check this article:
    Configuring Multiple Authentication Providers for SharePoint 2007
    http://blogs.msdn.com/sharepoint/archive/2006/08/16/configuring-multiple-authentication-providers-for-sharepoint-2007.aspx
    And note:
    "Use Policies sparingly: The concept described above for adding a user or group via the web application Policy should only be used to provide a way for an FBA administrator to access the site.  Policies are very coarsely grained compared to the fine grain permissions that can be configured and granted within individual sites, lists and items.  Once you’ve added your site administrator via Policy, all other users and groups should be added from within the site itself"

    If your question, how to make existing ASP.NET 2.0 membership users to actual SharePoint users, then you can follow Milan's recommendation:

    using (SPSite site = new SPSite(http://yoursite))
    {
      using (SPWeb web = site.OpenWeb())
      {
        MembershipUserCollection membershipCol = Membership.GetAllUsers();
        foreach (MembershipUser member in membershipCol)
        {
          web.EnsureUser(mu.UserName);
        }
      }
    }

    If you have to create new users, you can do that using the ASP.NET 2.0 Memebership and Role provider API, for example add user with Membership.CreateUser method (http://msdn.microsoft.com/en-us/library/system.web.security.membership.createuser.aspx).

    Peter

    Friday, August 28, 2009 7:59 AM
  • Thank You All, for the valuable information.I am looking for adding membership users to share point site.
    Vasavi.
    Friday, August 28, 2009 8:13 PM
  • Hi Vasavi,

    It's my pleasure. Let us know if you need further assistance.

    Peter
    Saturday, August 29, 2009 7:28 AM