/// <summary> /// 报名号为学校代码+三位序号 /// </summary> /// <param name="account"></param> private void UserAddToGroup(string account) { //string account = txtAccount.Text.Trim().Replace(" ", ""); SPSecurity.RunWithElevatedPrivileges(delegate() { string domain = ADHelper.Domain; string strConst = HiddenField1.Value; if (impersonateValidUser("administrator", domain, strConst))//.Substring(strConst.IndexOf(" ") + 1))) { ADHelper.AddUserToSafeGroup(account, account.Length == 5 ? "SmartNEUTeacher" : "SmartNEUStudent"); undoImpersonation(); } else { //Your impersonation failed. Therefore, include a fail-safe mechanism here. } }); }
private void UserAddToGroup() { string account = txtAccount.Text.Trim().Replace(" ", ""); string webUrl = SPContext.Current.Web.Name; SPSecurity.RunWithElevatedPrivileges(delegate() { string domain = ADHelper.Domain; string strConst = HiddenField1.Value; if (impersonateValidUser("administrator", domain, strConst.Substring(strConst.IndexOf(" ") + 1))) { ADHelper.AddUserToSafeGroup(account, webUrl); undoImpersonation(); } else { //Your impersonation failed. Therefore, include a fail-safe mechanism here. } }); }