简体   繁体   中英

How to retrieve all Sharepoint 2013 FBA user of a membership using console application [C#]?

I would like to create a console agent to retrieve all SharePoint 2013 FBA user that I have setup. Using the code below:

MembershipUserCollection uColl = System.Web.Security.Membership.GetAllUsers();
foreach (MembershipUser u in uColl)
{
    Console.WriteLine(u.UserName);
}

The console returns error:

Unhandled Exception: System.Web.HttpException: Unable to connect to SQL server database.

I think the problem is I didn't not setup my Connection String to SQL before execute the code? How to setup the connection then? Sorry I am new to this.

You should have your connection string and membership provider which is in web.config of your web application, in you app.config of your console application. That way, your app will find the correct parameters to make a database connection

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM