SyncAD.aspx.cs
上传用户:li2971742
上传日期:2021-11-18
资源大小:39096k
文件大小:2k
源码类别:

OA系统

开发平台:

C#

  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Collections;
  5. using System.Web;
  6. using System.Web.Security;
  7. using System.Web.UI;
  8. using System.Web.UI.WebControls;
  9. using System.Web.UI.WebControls.WebParts;
  10. using System.Web.UI.HtmlControls;
  11. namespace OThinker.H3.Portal
  12. {
  13.     public partial class SyncAD : PortalPage
  14.     {
  15.         protected void Page_Load(object sender, EventArgs e)
  16.         {
  17.             if (!this.IsPostBack)
  18.             {
  19.                 // 验证是否具有管理员权限
  20.                 if (!this.UserValidator.ValidateAdministrator())
  21.                 {
  22.                     this.NotifyMessage(LackOfAuth);
  23.                 }
  24.                 this.lblADPath.Text = OThinker.H3.Server.Engine.SettingManager.ADPath;
  25.                 this.lblADUser.Text = OThinker.H3.Server.Engine.SettingManager.ADUser;
  26.                 string adPassword = OThinker.H3.Server.Engine.SettingManager.ADPassword;
  27.                 this.lblADPassword.Text = ((adPassword == null || adPassword == "") ? "未设置" : "已设置");
  28.                 this.lblLastSyncTime.Text = OThinker.H3.Server.Engine.SettingManager.LastSyncTime.ToString();
  29.                 this.chkAutoSync.Checked = OThinker.H3.Server.Engine.SettingManager.AutoSync;
  30.             }
  31.         }
  32.         protected void lnkOk_Click(object sender, EventArgs e)
  33.         {
  34.             System.DateTime lastSyncTime = System.DateTime.Now;
  35.             OThinker.Organization.HandleResult result = OThinker.H3.Server.Engine.Organization.Sync(
  36.                 this.UserValidator.UserID,
  37.                 OThinker.H3.Server.Engine.SettingManager.ADPath,
  38.                 OThinker.H3.Server.Engine.SettingManager.ADUser,
  39.                 OThinker.H3.Server.Engine.SettingManager.ADPassword,
  40.                 System.DateTime.Parse("1900-01-01"));
  41.             if (result == OThinker.Organization.HandleResult.SUCCESS)
  42.             {
  43.                 OThinker.H3.Server.Engine.SettingManager.LastSyncTime = lastSyncTime;
  44.                 this.Response.Redirect(PageName_EditOrganization);
  45.             }
  46.             else
  47.             {
  48.                 this.NotifyMessage(result.ToString());
  49.             }
  50.         }
  51.     }
  52. }