Hi ccoulson,
I was able to add uses into my SharePoint Site from a csv file, thanks to a snippet of code from this site [http://social.msdn.microsoft.com/Forums/eu/sharepointdevelopment/thread/86d20692-e53c-4e48-990e-7beeb498d7e0]
[system.reflection.assembly]::LoadWithPartialName("Microsoft.Sharepoint")
#importing users from CSV file and adding each user to sharepoint site ex: http://dev:8888
$SPSite = New-Object Microsoft.SharePoint.SPSite("http://dev:8888");
$OpenWeb = $SpSite.OpenWeb();
$viewersGroup = $OpenWeb.SiteGroups | Where-Object {$_.Name -match "NewGroup3"};
if($viewersGroup -eq $null)
{
}
else
{
foreach ( $row in import-csv users.CSV | Select sAMAccountName, mail, FullName )
{
$viewersGroup.AddUser($row.sAMAccountName,$row.mail,$row.FullName,"");
}
}
$OpenWeb.Update();
$OpenWeb.Dispose();
$SPSite.Dispose();
But this method bypasses the FBA Membership process (which is expected) and the user doesn’t show up in the ‘aspnetdb’ database.
The bulk delete option you suggested in your previous reply, also looks like it directly removes users from a certain SharePoint group.
Is there any way to actually make the users appear (using powershell) in the FBA database as well as the SharePoint (WSS_Content) database?
I was exploring your FBA Pack code and noticed that the user is actually created in your MembershipRequest.cs file.
In line 389 of the file,
newUser = membership.CreateUser(request.UserName, request.Password, request.UserEmail, request.PasswordQuestion, request.PasswordAnswer, true, null, out createStatus);
is where the new user appears to be created.
Would I have to use powershell to replicate this action (as well as define the variables for MembershipRequest variables)?
From what I understand,
- ·
‘membership’ variable is a variable of type MembershipProvider.
- ·
‘request’ is a variable of type MembershipRequest.
Thank you for your time. Advice is greatly appreciated.