SyncAllUsers.aspx.cs
资源名称:H3_OA.rar [点击查看]
上传用户:li2971742
上传日期:2021-11-18
资源大小:39096k
文件大小:3k
源码类别:
OA系统
开发平台:
C#
- using System;
- using System.Collections;
- using System.Configuration;
- using System.Data;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.HtmlControls;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- namespace OThinker.H3.Portal
- {
- public partial class SyncAllUsers : PortalPage
- {
- protected string ParentID
- {
- get
- {
- return this.Request.QueryString[Param_Parent];
- }
- }
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!this.IsPostBack)
- {
- // 验证是否具有管理员权限
- if (!this.UserValidator.ValidateAdministrator())
- {
- this.NotifyMessage(LackOfAuth);
- }
- this.lblADPath.Text = OThinker.H3.Server.Engine.SettingManager.ADPath;
- this.lblADUser.Text = OThinker.H3.Server.Engine.SettingManager.ADUser;
- string adPassword = OThinker.H3.Server.Engine.SettingManager.ADPassword;
- this.lblADPassword.Text = ((adPassword == null || adPassword == "") ? "未设置" : "已设置");
- }
- }
- protected void lnkOk_Click(object sender, EventArgs e)
- {
- try
- {
- // 查询满足条件的用户
- string[] users = OThinker.H3.Server.Engine.Organization.QueryADUsers(
- OThinker.H3.Server.Engine.SettingManager.ADPath,
- OThinker.H3.Server.Engine.SettingManager.ADUser,
- OThinker.H3.Server.Engine.SettingManager.ADPassword,
- null);
- if (users != null)
- {
- foreach (string userAlias in users)
- {
- OThinker.Organization.HandleResult result = OThinker.Organization.HandleResult.SUCCESS;
- OThinker.Organization.User user = OThinker.H3.Server.Engine.Organization.CreateUser(
- OThinker.H3.Server.Engine.SettingManager.ADPath,
- OThinker.H3.Server.Engine.SettingManager.ADUser,
- OThinker.H3.Server.Engine.SettingManager.ADPassword,
- userAlias,
- ref result);
- user.ParentID = this.ParentID;
- OThinker.H3.Server.Engine.Organization.AddUnit(this.UserValidator.UserID, user, ref result);
- }
- }
- }
- catch
- {
- this.NotifyMessage("与活动目录连接出现异常,请检查:1、是否有设置活动目录信息;2、运行工作流服务的帐号是否有访问活动目录的权限;3、域服务器是否可以访问");
- }
- // 显示结果
- this.NotifyResult(
- OThinker.Organization.HandleResult.SUCCESS,
- true,
- this.Request.QueryString[Param_ExpandPath]);
- }
- }
- }