private static void FillContext(AD2DBTransferContext context, string parentOU) { string rootPath = AD2DBHelper.TranslateDNToFullPath(parentOU); DataRowView[] drvs = context.ADOguAllPathView.FindRows(rootPath); ExceptionHelper.FalseThrow(drvs.Length > 0, "不能在机构人员数据库中找到父对象\"{0}\"", rootPath); context.ParentGuid = drvs[0]["GUID"].ToString(); context.ParentOriginalSort = drvs[0]["ORIGINAL_SORT"].ToString(); context.ParentChildrenCount = Convert.ToInt32(drvs[0]["CHILDREN_COUNTER"]); }
private static void InsertOrganizations(SearchResult sr, AD2DBTransferContext context) { //开始添加AD的比较数据 ADHelper helper = context.InitialParams.DirectoryHelper; DataTable oguTable = context.ADData.Tables["ORGANIZATIONS"]; DataRow dr = oguTable.NewRow(); dr["GUID"] = helper.GetSearchResultPropertyStrValue("objectGuid", sr); dr["PARENT_GUID"] = context.ParentGuid; string name = helper.GetSearchResultPropertyStrValue("name", sr); dr["OBJ_NAME"] = name; string displayName = helper.GetSearchResultPropertyStrValue("displayName", sr); displayName = string.IsNullOrEmpty(displayName) ? name : displayName; dr["DISPLAY_NAME"] = NormalizeName(displayName); dr["DESCRIPTION"] = helper.GetSearchResultPropertyStrValue("description", sr); dr["ALL_PATH_NAME"] = AD2DBHelper.TranslateDNToFullPath(helper.GetSearchResultPropertyStrValue("distinguishedName", sr)); string innerSort = GetInnerSortAndIncCounter(context); string originalSort = context.ParentOriginalSort + innerSort; dr["ORIGINAL_SORT"] = originalSort; dr["GLOBAL_SORT"] = originalSort; dr["RANK_CODE"] = AD2DBHelper.ConvertDepartmentRankCode(helper.GetSearchResultPropertyStrValue("physicalDeliveryOfficeName", sr)).ToString(); dr["CHILDREN_COUNTER"] = 0; dr["INNER_SORT"] = innerSort; dr["ORG_TYPE"] = (int)AD2DBHelper.TranslateDeptTypeDefine(sr); dr["ORG_CLASS"] = (int)AD2DBHelper.TranslateDeptClass(helper.GetSearchResultPropertyStrValue("c", sr)); dr["STATUS"] = 1; dr["SEARCH_NAME"] = name + " " + NormalizeName(displayName); oguTable.Rows.Add(dr); }
private static void InsertOUUser(SearchResult sr, AD2DBTransferContext context) { ADHelper helper = context.InitialParams.DirectoryHelper; string logonName = helper.GetSearchResultPropertyStrValue("samAccountName", sr); string pinyin = logonName; string displayName = helper.GetSearchResultPropertyStrValue("displayName", sr); //by v-zhangbm 20120220 start //判断是否需要更新电话号码 string mobile = helper.GetSearchResultPropertyStrValue("mobile", sr); string telephoneNumber = helper.GetSearchResultPropertyStrValue("telephoneNumber", sr); //特殊处理手机号 int num = mobile.IndexOf('/'); string newmobile = string.Empty; if (num != -1) { newmobile = mobile.Substring(num - 11, 11); } else if (mobile.Length >= 11) { newmobile = mobile.Substring(mobile.Length - 11, 11); } string email = helper.GetSearchResultPropertyStrValue("mail", sr); string newEmail = string.Empty; if (!string.IsNullOrEmpty(email)) { int index = email.IndexOf('@'); if (index != -1) { newEmail = email.Substring(0, index); } } //by v-zhangbm 20120220 end if (string.IsNullOrEmpty(displayName)) { string firstName = helper.GetSearchResultPropertyStrValue("givenName", sr); string lastName = helper.GetSearchResultPropertyStrValue("sn", sr); displayName = lastName + firstName; //DisplayName= givenname + sn } DataTable ouusersTable = context.ADData.Tables["OU_USERS"]; DataRow dr = ouusersTable.NewRow(); dr["USER_GUID"] = helper.GetSearchResultPropertyStrValue("objectGuid", sr); dr["PARENT_GUID"] = context.ParentGuid; dr["ALL_PATH_NAME"] = AD2DBHelper.TranslateDNToFullPath(helper.GetSearchResultPropertyStrValue("distinguishedName", sr)); dr["DISPLAY_NAME"] = displayName; dr["OBJ_NAME"] = helper.GetSearchResultPropertyStrValue("name", sr); if (helper.GetUserAccountPolicy(sr).UserAccountDisabled) { dr["STATUS"] = 3; } else { dr["STATUS"] = 1; } string innerSort = GetInnerSortAndIncCounter(context); string originalSort = context.ParentOriginalSort + innerSort; dr["ORIGINAL_SORT"] = originalSort; dr["GLOBAL_SORT"] = originalSort; dr["RANK_NAME"] = helper.GetSearchResultPropertyStrValue("title", sr); dr["DESCRIPTION"] = helper.GetSearchResultPropertyStrValue("description", sr); dr["ATTRIBUTES"] = (int)AD2DBHelper.TranslateUserAttributes(sr); //增加几个搜索条件v-zhangbm 20120220 dr["SEARCH_NAME"] = displayName + " " + pinyin + " " + logonName + " " + telephoneNumber + " " + newmobile + " " + newEmail; ouusersTable.Rows.Add(dr); }
public void InitContext() { using (DbContext context = DbContext.GetContext(this.initialParams.AccreditAdminConnectionName)) { FillData(this.OriginalData, "SELECT * FROM USERS", "USERS", context); FillData(this.OriginalData, "SELECT * FROM OU_USERS ORDER BY ALL_PATH_NAME", "OU_USERS", context); FillData(this.OriginalData, "SELECT * FROM ORGANIZATIONS ORDER BY ALL_PATH_NAME", "ORGANIZATIONS", context); } using (DbContext context = DbContext.GetContext(this.initialParams.UserInfoExtend)) { FillData(this.OriginalData, "SELECT * FROM USERS_INFO_EXTEND", "USERS_INFO_EXTEND", context); } CloneDataSetSchema(OriginalData, ADData); InitRootOURow( OriginalData.Tables["ORGANIZATIONS"], ADData.Tables["ORGANIZATIONS"], ADToDBConfigSettings.GetConfig().RootOUName); DataRow newRow = InitRootOURow( OriginalData.Tables["ORGANIZATIONS"], ADData.Tables["ORGANIZATIONS"], AD2DBHelper.TranslateDNToFullPath(this.initialParams.Root.Properties["distinguishedName"].Value.ToString())); if (newRow != null) { newRow["CHILDREN_COUNTER"] = 0; } ADOguAllPathView = new DataView(ADData.Tables["ORGANIZATIONS"]); ADOguAllPathView.Sort = "ALL_PATH_NAME"; ADOguGuidView = new DataView(ADData.Tables["ORGANIZATIONS"]); ADOguGuidView.Sort = "GUID"; OriginalOguGuidView = new DataView(OriginalData.Tables["ORGANIZATIONS"]); OriginalOguGuidView.Sort = "GUID"; OriginalOguParentGuidView = new DataView(OriginalData.Tables["ORGANIZATIONS"]); OriginalOguParentGuidView.Sort = "PARENT_GUID"; OriginalOuUserParentGuidView = new DataView(OriginalData.Tables["OU_USERS"]); OriginalOuUserParentGuidView.Sort = "PARENT_GUID"; ADUsersGuidView = new DataView(ADData.Tables["USERS"]); ADUsersGuidView.Sort = "GUID"; UsersGuidView = new DataView(OriginalData.Tables["USERS"]); UsersGuidView.Sort = "GUID"; ADOuUserParentGuidView = new DataView(ADData.Tables["OU_USERS"]); ADOuUserParentGuidView.Sort = "USER_GUID,PARENT_GUID"; ADUserExtendGuidView = new DataView(ADData.Tables["USERS_INFO_EXTEND"]); ADUserExtendGuidView.Sort = "ID"; OriginalUserExtendGuidView = new DataView(OriginalData.Tables["USERS_INFO_EXTEND"]); OriginalUserExtendGuidView.Sort = "ID"; OriginalOUUserParentUserGuidView = new DataView(OriginalData.Tables["OU_USERS"]); OriginalOUUserParentUserGuidView.Sort = "USER_GUID,PARENT_GUID"; OriginalOUUserUserGuidView = new DataView(OriginalData.Tables["OU_USERS"]); OriginalOUUserUserGuidView.Sort = "USER_GUID"; }