protected void btnExportUsersInList_Click(object sender, EventArgs e) { this.BuildUserList(); Sitecore.Data.Database db = Sitecore.Configuration.Factory.GetDatabase("master"); Sitecore.Install.PackageProject document = new PackageProject(); document.Metadata.PackageName = "SitecoreUserExport-" + DateTime.Now.ToString("yyyy-MM-dd-hhmmss"); document.Metadata.Author = "Autogenerated by SitecoreExtension.SitecoreUserImporter"; Sitecore.Install.Security.SecuritySource securitySource = new SecuritySource(); securitySource.Name = "Users To Export"; int count = 1; int packageCount = 0; foreach (string key in usersByEmail.Keys) { UserData userData = usersByEmail[key]; string userName = GetFullName(userData.Login); if (Sitecore.Security.Accounts.User.Exists(userName)) { securitySource.AddAccount(new AccountString(userName, AccountType.User)); packageCount++; } count++; } document.Sources.Add(securitySource); document.SaveProject = true; if (packageCount > 0) { //path where the zip file package is saved using (Sitecore.Install.Zip.PackageWriter writer = new Sitecore.Install.Zip.PackageWriter(this.userExportFilePath)) { Sitecore.Context.SetActiveSite("shell"); writer.Initialize(Sitecore.Install.Installer.CreateInstallationContext()); Sitecore.Install.PackageGenerator.GeneratePackage(document, writer); Sitecore.Context.SetActiveSite("website"); } divDebug.InnerHtml = string.Format("<h1>{0} Users packaged, file location: </h1>{1}", packageCount, this.userExportFilePath); } else { divDebug.InnerHtml = string.Format("<h1>Could not find any users</h1>"); } }
public SecuritySource Get(SecuritySource t) { throw new NotImplementedException(); }
protected override void BeginProcessing() { source = new SecuritySource { Name = Name }; //Create source – source should be based on BaseSource }
protected override void BeginProcessing() { source = new SecuritySource { Name = Name }; //Create source – source should be based on BaseSource }