private static GetAccountName ( string key ) : string | ||
key | string | |
리턴 | string |
protected new void InstallUser(PackageEntry entry) { string accountName = AccountInstaller.GetAccountName(entry.Key); if (User.Exists(accountName)) { Log.Info(string.Format("Installing of entry '{0}' was skipped. User already exists.", (object)accountName), (object)this); this.UIEvents.ShowWarning(string.Format(Translate.Text("User '{0}' will not be installed since the user already exists."), (object)accountName), "user already exists"); } else { XmlDocument xml = AccountInstaller.ReadXml(entry); if (!Context.User.IsAdministrator && this.TryingToInstallAdmin(xml, accountName)) { return; } string password = AccountInstaller.GetPassword(xml); User user = (User)null; try { user = User.Create(accountName, password); this.SetUserProfile(user, xml); this.SetUserProperties(user, xml); this.SetUserRoles(user, xml); } catch (Exception ex) { try { if ((Account)user != (Account)null) { user.Delete(); } } catch { } Log.Error(string.Format("Failed to install the user '{0}'", (object)accountName), ex, (object)this); throw; } Log.Info(string.Format("User '{0}' has been installed successfully", (object)user.Name), (object)this); } }
public override void Put(PackageEntry entry) { this._skipAll = (bool)typeof(Sitecore.Install.Security.AccountInstaller).GetField("_skipAll", BindingFlags.Instance | BindingFlags.NonPublic).GetValue((object)this); if (this._skipAll) { return; } string[] strArray = entry.Key.Split('/'); if (strArray[0] != "security") { return; } if (!AccountInstaller.ContextUserHasEnoughRights()) { JobContext.Alert(Translate.Text("You do not have enough permissions to install security accounts")); this._skipAll = true; } else if (strArray.Length < 3) { Log.Error(string.Format("Bad entry key '{0}'", (object)entry.Key), (object)this); } else { if (strArray.Length > 3) { string domainName = strArray[2]; if (!DomainManager.DomainExists(domainName)) { this.UIEvents.ShowWarning(string.Format(Translate.Text("Unable to create the user '{0}' because domain '{1}' doesn't exist."), (object)AccountInstaller.GetAccountName(entry.Key), (object)domainName), "domain doesn't exist" + domainName); return; } } string str = strArray[1]; try { if (str == "users") { this.InstallUser(entry); } else if (str == "roles") { this.InstallRole(entry); } else { Log.Error(string.Format("Unexpected account type '{0}'", (object)entry.Key), (object)this); } } catch (ThreadAbortException) { throw; } catch (Exception ex) { Log.Error(string.Format("Error installing entry '{0}'", (object)entry.Key), ex, (object)this); } } }