项目需求:
同步人事系统的组织架构-对应AD的OU树
同步人事系统的员工-对应AD的用户

 

创建OU 名字不能重复,需要父级路径(parentOrganizeUnit)以及新ou的名字(name),如果最父级则上级路径为域节点
DirectoryEntry CreateOrganizeUnit(string OrgId,string name, string parentOrganizeUnit,int Id,ADInfo ad)

更改OU名称 需要旧的OU路径(oldUnit)以及“OU=新OUName”(newUnit)
DirectoryEntry UpdateOrganizeUnit(string newUnit, string OUName, string oldUnit, int Id,ADInfo ad) 使用Renname

更改OU上级 需要新的上级路径(newparentOrganizeUnit)旧OU的路径(oldUnit)
DirectoryEntry MoveOrganizeUnit(string oldUnit, string newparentOrganizeUnit, int Id,ADInfo ad)

创建ou用户需要ou路径(orgPath) 以及用户信息(user)
AddADAccount(string orgPath, EmpInfo user, int Id,ADInfo ad)
注意ou树下的名字是cn字段(不能重复),cn需要重新赋值时用rename
sAMAccountName 用户(不能重复)
userPrincipalName 有域名的用户名 (不能重复)
邮箱为空不能赋值(mail)

移动用户 需要用户路径(user_path)以及OU路径(target_path)
MoveUser(string user_path, string target_path,string OuName, int Id,ADInfo ad)

设置密码

 NewUser.Invoke("SetPassword", new object[] { accountPwd });

设置用户下次登录必须修改密码

 NewUser.Properties["pwdLastSet"].Value = 0;

对应TXT 代码

 

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Quartz;
using vxTalent.Schedule.DALBase;
using System.Data;
using System.DirectoryServices;
using vxTalent.Schedule.DALBase.AD;
using System.Configuration;
using System.Reflection;
using Microsoft.International.Converters.PinYinConverter;
namespace vxTalent.User.ModuleJob.AD
{public  class ADSynData : IJob{private static readonly log4net.ILog logger = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);private static bool IsSendSMSLocked = false;private static readonly object lynLock = new object();ADSynDataAccess asy = new ADSynDataAccess();/// <summary>/// 域名/ </summary>//private string _domain;/ <summary>/ 主机域IP/ </summary>//private string _domainIp;/ <summary>/ 管理员账号/ </summary>//private string adminUser;/ <summary>/ 管理员密码/ </summary>//private string adminPwd;/ <summary>/ 路径的最前端/ </summary>//private string _ldapIdentity;/// <summary>/// 路径的最后端/// </summary>string accountPwd = ObjConvert.ObjString(ConfigurationManager.AppSettings["AdInitPwd"]) == "" ? "abc12345!" : ObjConvert.ObjString(ConfigurationManager.AppSettings["AdInitPwd"]);int i = 0; //重复变量private string sAMAccountName = "";protected int AdRepeatNum = ObjConvert.ObjInt(ConfigurationManager.AppSettings["AdRepeatNum"]) == 0 ? 8 : ObjConvert.ObjInt(ConfigurationManager.AppSettings["AdRepeatNum"]);string cnName = "";public void Test() {string domain_ = row["ADName"].ToString();string domainIp_ = row["ADUrl"].ToString();string adminUser_ = row["ADName"].ToString() + "\\" + row["UserName"].ToString();string adminPwd_ = row["Pwd"].ToString();string ldapIdentity_ = "LDAP://" + domainIp_ + "/";string houzhui_ = row["ADSur"].ToString() != "" ? row["ADSur"].ToString() : "com";string suffixPath_ = "DC=" + domain_ + ",DC=" + houzhui_;ADInfo ad = new ADInfo{adsur = houzhui_,domain = domain_,domainIp = domainIp_,ldapIdentity = ldapIdentity_,suffixPath = suffixPath_,adminPwd = adminPwd_,adminUser = adminUser_,houzhui=houzhui_,dbCon = dbString};RunData(dbString, ad);}/// <summary>/// 遍历每个 库的待同步数据/// </summary>/// <param name="conn"></param>protected void RunData(string conn,ADInfo ad ) {DataTable waitingData = asy.GetWaitingData(conn);if (waitingData != null && waitingData.Rows.Count > 0) {string operation = "";foreach (DataRow item in waitingData.Rows){try{int synId = ObjConvert.ObjInt(item["Id"]);operation = ObjConvert.ObjString(item["Operation"]);//部门操作if (ObjConvert.ObjString(item["SynType"]) == "1"){string path = "", orgName = "", relateId = ObjConvert.ObjString(item["RelateID"]);DataTable orgDatatable = asy.GetOrgById(conn, relateId);string parentOrgId = "";string name = "";if (orgDatatable != null && orgDatatable.Rows.Count > 0){name = ObjConvert.ObjString(orgDatatable.Rows[0]["organizationalname"]);parentOrgId = ObjConvert.ObjString(orgDatatable.Rows[0]["ParentOrganizationalID"]);}else{DataTable hisTable = asy.GetHistoryOrg(conn, relateId);if (hisTable != null && hisTable.Rows.Count > 0){name = ObjConvert.ObjString(hisTable.Rows[0]["organizationalname"]);parentOrgId = ObjConvert.ObjString(hisTable.Rows[0]["ParentOrganizationalID"]);}}switch (operation){case "Add"://parentPath = asy.GetPathOrgId(conn, ObjConvert.ObjString(orgDatatable.Rows[0]["ParentOrganizationalID"]));CreateOrganizeUnit(relateId, name, parentOrgId, synId, ad); break;case "ParentChange"://MovePath = asy.GetPathOrgId(conn, ObjConvert.ObjString(item["MergeDeleteId"]));MoveOrganizeUnit(relateId, ObjConvert.ObjString(item["MergeDeleteId"]), synId, ad); break;case "Update":// string repl=  oldOrgName.Split('/')[0];orgName = "OU=" + name;UpdateOrganizeUnit(orgName, name, relateId, synId, ad); break;case "Merge":string[] arrDeleteId = ObjConvert.ObjString(item["MergeDeleteId"]).Split(',');MergeOu(arrDeleteId, ObjConvert.ObjString(item["RelateID"]), name, synId, ad);break;case "Disable":   //禁用加+封存orgName = "OU=" + name + "(封存)";UpdateOrganizeUnit(orgName, name + "(封存)", relateId, synId, ad); break;}}else{ //人员操作DataTable empTable = asy.GetEmpById(conn, ObjConvert.ObjInt(item["RelateID"]));EmpInfo empDetail = new EmpInfo();if (empTable != null && empTable.Rows.Count > 0){string CNName = ObjConvert.ObjString(empTable.Rows[0]["CNName"]);string piyin = ObjConvert.ObjString(empTable.Rows[0]["Pinyin"]);if (string.IsNullOrEmpty(piyin)){piyin = ObjConvert.ObjStringToLower(PingYinHelper.ConvertToAllSpell(CNName));}string ADName = ObjConvert.ObjString(empTable.Rows[0]["CN_ADName"]);empDetail.emloyeeID = ObjConvert.ObjString(empTable.Rows[0]["EmpCode"]);empDetail.sAMAccountName = string.IsNullOrEmpty(ADName) ? ObjConvert.ObjStringToLower(piyin) : ObjConvert.ObjStringToLower(ADName);empDetail.userPrincipalName = empDetail.sAMAccountName + "@" + ad.domain + "." + ad.adsur;empDetail.employeeType = ObjConvert.ObjString(empTable.Rows[0]["empTypeText"]);empDetail.DepartmentName = ObjConvert.ObjString(empTable.Rows[0]["OrganizationalName"]);empDetail.Mail = ObjConvert.ObjString(empTable.Rows[0]["Email"]);empDetail.DisplayName = CNName;if (CNName.Length > 1){empDetail.Surname = CNName.Substring(0, 1);//姓empDetail.GivenName = CNName.Substring(1, CNName.Length - 1);//名}else{empDetail.Surname = CNName;}empDetail.Department = ObjConvert.ObjString(empTable.Rows[0]["OrganizationalID"]);empDetail.Oupath = GetOuDirectory(empDetail.Department, ad).Path;//string newouName = asy.GetOrgName(conn, ObjConvert.ObjString(empTable.Rows[0]["OrganizationalID"]));string newouName = "";string newPath = "";switch (operation){case "Add":i = 0;cnName = empDetail.DisplayName;sAMAccountName = empDetail.sAMAccountName;AddADAccount(empDetail.Oupath, empDetail, synId, ad); break;case "Dimission":DisableUser(empDetail.sAMAccountName, synId, ad); break;case "Mobilize":if (ObjConvert.ObjString(item["MergeDeleteId"]) != ""){newouName = asy.GetOrgName(conn, ObjConvert.ObjString(item["MergeDeleteId"]));newPath = GetOuDirectory(ObjConvert.ObjString(item["MergeDeleteId"]), ad).Path;}else {newouName = asy.GetOrgName(conn, empDetail.Department);newPath = GetOuDirectory(empDetail.Department, ad).Path;}MoveUser(GetDirectoryEntryByAccount(empDetail.sAMAccountName, ad).Path, newPath, newouName, synId, ad);break;case "Update": UpdateUser(empDetail, synId, ad); break;case "Rehab":EnableUser(empDetail.sAMAccountName, synId, ad);UpdateUser(empDetail, synId, ad);newouName = asy.GetOrgName(conn, ObjConvert.ObjString(empTable.Rows[0]["OrganizationalID"]));MoveUser(GetDirectoryEntryByAccount(empDetail.sAMAccountName, ad).Path, empDetail.Oupath, newouName, synId, ad);break;  //重聘启用 用户  更新 并且可能移动部门}}}}catch (Exception e) { logger.Error(e.Message); }}}}#region 创建OU/// <summary>/// 创建OUl/// </summary>/// <param name="adminName">管理员名称</param>/// <param name="adminPassword">管理员密码</param>/// <param name="name">创建的OU名称</param>/// <param name="parentOrganizeUnit">父组织单位</param>/// <returns>目录实体</returns>public DirectoryEntry CreateOrganizeUnit(string OrgId,string name, string parentOrganizeUnit,int Id,ADInfo ad){DirectoryEntry parentEntry = null;try{string parentPath = "";DirectoryEntry de = GetOuDirectory(parentOrganizeUnit,ad);if (de == null){parentPath = GetOrganizeNamePath("",ad);}else {parentPath = de.Path;}//示例顶级""parentEntry = new DirectoryEntry(parentPath, ad.adminUser, ad.adminPwd,AuthenticationTypes.Secure);DirectoryEntry organizeEntry = parentEntry.Children.Add("OU=" + name, "organizationalUnit");organizeEntry.Properties["postalCode"].Value = OrgId;organizeEntry.CommitChanges();//DomainUser._success = "组织单位添加成功!";logger.Info("创建OU成功" + name);asy.UpdateStatus(ad.dbCon,Id,"Success");return organizeEntry;}catch (System.DirectoryServices.DirectoryServicesCOMException ex){//DomainUser._failed = "添加组织单位失败!"+ex.Message.ToString();logger.Error("创建OU失败"+name+":"+ex.Message);asy.UpdateStatus(ad.dbCon, Id, "Error", ex.Message);return new DirectoryEntry();}finally{if (parentEntry != null){parentEntry.Dispose();}}}#endregion#region 更改OU名称public DirectoryEntry UpdateOrganizeUnit(string newUnit, string OUName, string oldUnit, int Id,ADInfo ad){DirectoryEntry parentEntry = null;try{List<DirectoryEntry> list = GetListDirectory(GetOuDirectory(oldUnit,ad).Path,ad);if (list != null && list.Count > 0) {foreach (DirectoryEntry item in list){item.Properties["department"][0] = OUName;item.CommitChanges();item.Dispose();}}//示例顶级""parentEntry = new DirectoryEntry(GetOuDirectory(oldUnit,ad).Path, ad.adminUser, ad.adminPwd,AuthenticationTypes.Secure);parentEntry.Rename(newUnit);parentEntry.CommitChanges();logger.Info("更新OU成功" + OUName);asy.UpdateStatus(ad.dbCon, Id, "Success");return parentEntry;}catch (System.DirectoryServices.DirectoryServicesCOMException ex){logger.Error("更改OU失败" + OUName + ":" + ex.Message);asy.UpdateStatus(ad.dbCon, Id, "Error", ex.Message);return new DirectoryEntry();}finally{if (parentEntry != null){parentEntry.Dispose();}}}#endregion#region 移动OUpublic DirectoryEntry MoveOrganizeUnit(string oldUnit, string newparentOrganizeUnit, int Id,ADInfo ad){DirectoryEntry Entry = null;try{//示例顶级""Entry = new DirectoryEntry(GetOuDirectory(oldUnit, ad).Path, ad.adminUser, ad.adminPwd,AuthenticationTypes.Secure);DirectoryEntry parentEntry = new DirectoryEntry(GetOuDirectory(newparentOrganizeUnit, ad).Path, ad.adminUser, ad.adminPwd,AuthenticationTypes.Secure);Entry.MoveTo(parentEntry);Entry.CommitChanges();logger.Info("更改OU父节点成功" + oldUnit);asy.UpdateStatus(ad.dbCon, Id, "Success");return Entry;}catch (System.DirectoryServices.DirectoryServicesCOMException ex){logger.Error("更改OU父节点:" + oldUnit + ":" + ex.Message);asy.UpdateStatus(ad.dbCon, Id, "Error", ex.Message);return new DirectoryEntry();}finally{if (Entry != null){Entry.Dispose();}}}#endregion#region 合并OUpublic void MergeOu(string[] deleteArr, string newUnit, string OUName,int Id,ADInfo ad){//DataTable mergeEmpTable = asy.GetMergeListBySynId(ad.dbCon, Id);try{if (deleteArr.Length > 0){DirectoryEntry t = new DirectoryEntry(GetOuDirectory(newUnit, ad).Path, ad.adminUser, ad.adminPwd);for (int i = 0; i < deleteArr.Length; i++){List<DirectoryEntry> list = GetListDirectory(GetOuDirectory(deleteArr[i],ad).Path,ad);if (list != null && list.Count > 0){//if (mergeEmpTable != null && mergeEmpTable.Rows.Count > 0)//{foreach (DirectoryEntry item in list){string saName = ObjConvert.ObjString(item.Properties["sAMAccountName"][0]);//DataRow[] dtrows=  mergeEmpTable.Select("CN_ADName='" + saName + "'");//if (dtrows != null && dtrows.Count() > 0) { //服务逻辑是先同步部门操作,合并的时候//可能发生  已经从这个部门调转出去了,但是服务先合并到别的部门了,所有没法后续的人员调岗操作了//同时更改部门用户名字item.Properties["department"][0] = OUName;item.CommitChanges();//更改OUitem.MoveTo(t);item.Dispose();//}}//}}}logger.Info("合并OU成功" + OUName);asy.UpdateStatus(ad.dbCon, Id, "Success");}}catch (Exception t){logger.Error("合并异常:" + OUName + t.Message);asy.UpdateStatus(ad.dbCon, Id, "Error", t.Message);}}#endregion#region 组织结构下添加AD账户/// <summary>/// 添加AD账户/// </summary>/// <param name="organizeName">组织名称</param>/// <param name="user">域账户</param>/// <returns>添加是否成功</returns>public void AddADAccount(string orgPath, EmpInfo user, int Id,ADInfo ad){DirectoryEntry entry = null;try{if (IsExistOuPath(orgPath,ad) && user != null){if (!IsAccExists(user.sAMAccountName, ad)){string cn = GetCnName(user.DisplayName, ad);entry = new DirectoryEntry(orgPath, ad.adminUser, ad.adminPwd, AuthenticationTypes.Secure);//增加账户到域中DirectoryEntry NewUser = entry.Children.Add("CN=" + cn, "user");NewUser.Properties["sAMAccountName"].Add(user.sAMAccountName); //accountNewUser.Properties["userPrincipalName"].Value = user.userPrincipalName; //user logon name,xxx@bdxy.comNewUser.Properties["employeeID"].Value = user.emloyeeID;NewUser.Properties["employeeType"].Value = user.employeeType;NewUser.Properties["Department"].Value = user.DepartmentName;NewUser.Properties["displayName"].Value = user.DisplayName;// NewUser.Properties["name"].Value = user.DisplayName;//NewUser.Properties["Surname"].Value = user.Surname;NewUser.Properties["givenName"].Value = user.GivenName;NewUser.Properties["Sn"].Value = user.Surname;if (user.Mail != null && user.Mail != ""){NewUser.Properties["mail"].Value = user.Mail;}NewUser.CommitChanges();//设置密码//反射调用修改密码的方法(注意端口号的问题  端口号会引起方法调用异常)NewUser.Invoke("SetPassword", new object[] { accountPwd });//默认设置新增账户启用NewUser.Properties["userAccountControl"].Value = 0x200;NewUser.CommitChanges();//DomainUser._success = "账户添加成功!";logger.Info("账户添加成功" + user.sAMAccountName);asy.UpdateADPinyin(ad.dbCon, Id, user.sAMAccountName);asy.UpdateStatus(ad.dbCon, Id, "Success");}else {if (i <= AdRepeatNum){i++;user.sAMAccountName = sAMAccountName + "0" + i.ToString();user.userPrincipalName = sAMAccountName + "0" + i + "@" + ad.domain + "." + ad.houzhui;AddADAccount(orgPath, user, Id, ad);}logger.Error("创建OU重复:" + sAMAccountName + i.ToString() + "次");}}else{logger.Error("创建OU失败:在域中不存在直属组织单位" + user.sAMAccountName);asy.UpdateStatus(ad.dbCon, Id, "Error", "在域中不存在直属组织单位");}}catch (Exception ex){logger.Error("创建OU失败:" + sAMAccountName + ex.Message);asy.UpdateStatus(ad.dbCon, Id, "Error", ex.Message);}finally{if (entry != null){entry.Dispose();}}}#endregionpublic string GetCnName(string cn, ADInfo ad){if (i < AdRepeatNum){if (IsAccExistsCN(cn, ad)){cn = cnName + "0" + i.ToString();i++;GetCnName(cn, ad);}}return cn;}/// <summary>/// 移动用户(调岗)/// </summary>/// <param name="user_path">用户Path</param>/// <param name="target_path">目标path</param>/// <returns></returns>public string MoveUser(string user_path, string target_path,string OuName, int Id,ADInfo ad){try{DirectoryEntry u = new DirectoryEntry(user_path, ad.adminUser, ad.adminPwd);DirectoryEntry t = new DirectoryEntry(target_path, ad.adminUser, ad.adminPwd);//同时更改部门用户名字u.Properties["department"][0] = OuName;u.CommitChanges();//更改OUu.MoveTo(t);u.Dispose();logger.Info("用户调岗成功" + user_path);asy.UpdateStatus(ad.dbCon, Id, "Success");return u.Path;}catch(Exception ex){logger.Error("用户调岗失败:" + user_path + "," + target_path + ex.Message);asy.UpdateStatus(ad.dbCon, Id, "Error", ex.Message);return "";}}/// <summary>/// 初始化移动 用户/// </summary>/// <param name="user_path"></param>/// <param name="target_path"></param>/// <param name="OuName"></param>/// <param name="ad"></param>/// <param name="empCode"></param>/// <returns></returns>public string MoveUser(string user_path, string target_path, string OuName, ADInfo ad,string empCode){try{DirectoryEntry u = new DirectoryEntry(user_path, ad.adminUser, ad.adminPwd);DirectoryEntry t = new DirectoryEntry(target_path, ad.adminUser, ad.adminPwd);//同时更改部门用户名字u.Properties["department"].Value = OuName;u.CommitChanges();//更改OUu.MoveTo(t);u.Dispose();logger.Info("用户移动成功" + empCode +":"+ user_path);return u.Path;}catch (Exception ex){logger.Error("用户移动失败:" + empCode +":"+ user_path + "," + target_path + ex.Message);return "";}}/// <summary>/// 禁用指定的帐户(离职)/// </summary>/// <param name="de"></param>public static void DisableUser(DirectoryEntry de){//impersonate.BeginImpersonate();de.Properties["userAccountControl"][0] =0X0200 | 0X0002;de.CommitChanges();//impersonate.StopImpersonate();de.Close();}/// <summary>/// 禁用指定公共名称的用户/// </summary>/// <param name="commonName">用户公共名称</param>public void DisableUser(string sAMacc, int Id,ADInfo ad){try{DisableUser(GetDirectoryEntryByAccount(sAMacc,ad));logger.Info("用户禁用成功:" + sAMacc);asy.UpdateStatus(ad.dbCon, Id, "Success");}catch(Exception ex){logger.Error("用户禁用失败:" + sAMacc+ ex.Message);asy.UpdateStatus(ad.dbCon, Id, "Error", ex.Message);}}/// <summary>/// 启用指定的域账号/// </summary>/// <param name="sAMacc">用户的域账号名称</param>public bool EnableUser(string sAMacc, int Id, ADInfo ad){try{EnableUser(GetDirectoryEntryByAccount(sAMacc, ad));logger.Info("用户启用成功:" + sAMacc);asy.UpdateStatus(ad.dbCon, Id, "Success");return true;}catch (Exception ex){logger.Error("用户启用失败:" + sAMacc + ex.Message);asy.UpdateStatus(ad.dbCon, Id, "Error", ex.Message);return false;}}/// <summary>/// 启用指定帐户/// </summary>/// <param name="de"></param>public  void EnableUser(DirectoryEntry de){de.Properties["userAccountControl"][0] =0X0200;de.CommitChanges();de.Close();}/// <summary>/// 更新用户  (基本信息  显示名、员工类型、姓和名)/// </summary>/// <param name="user"></param>public void UpdateUser(EmpInfo user, int Id,ADInfo ad){try{if (IsAccExists(user.sAMAccountName, ad)){DirectoryEntry userEntry = GetDirectoryEntryByAccount(user.sAMAccountName, ad);//userEntry.Properties["cn"][0] = newDisplayName;userEntry.Rename("CN=" + user.DisplayName);userEntry.Properties["displayName"][0] = user.DisplayName;// userEntry.Properties["name"][0] = user.DisplayName;userEntry.Properties["employeeType"][0] = user.employeeType;userEntry.Properties["Sn"][0] = user.Surname;//姓userEntry.Properties["GivenName"][0] = user.GivenName;//名if (!string.IsNullOrEmpty(user.Mail)) {     userEntry.Properties["Mail"][0] = user.Mail;}//userEntry.Properties["Mail"][0] = user.Mail;//邮件//  userEntry.Rename("CN=" + newDisplayName);userEntry.CommitChanges();userEntry.Dispose();logger.Info("用户更新成功:" + user.sAMAccountName);asy.UpdateStatus(ad.dbCon, Id, "Success");}}catch (Exception ex){logger.Error("用户更新失败:" + user.sAMAccountName + ex.Message);asy.UpdateStatus(ad.dbCon, Id, "Error", ex.Message);}}public void UpdateUser(EmpInfo user, ADInfo ad){try{if (IsAccExists(user.sAMAccountName, ad)){DirectoryEntry userEntry = GetDirectoryEntryByAccount(user.sAMAccountName, ad);//userEntry.Properties["cn"][0] = newDisplayName;userEntry.Properties["displayName"].Value = user.DisplayName;userEntry.Properties["employeeID"].Value = user.emloyeeID;// userEntry.Properties["name"].Value = user.DisplayName;userEntry.Properties["employeeType"].Value = user.employeeType;userEntry.Properties["Sn"].Value = user.Surname;//姓userEntry.Properties["GivenName"].Value = user.GivenName;//名if (!string.IsNullOrEmpty(user.Mail)) { userEntry.Properties["Mail"].Value = user.Mail; }//  userEntry.Properties["Mail"].Value = user.Mail;//邮件//  userEntry.Rename("CN=" + newDisplayName);userEntry.CommitChanges();userEntry.Dispose();logger.Info("用户更新成功:" + user.sAMAccountName);}}catch (Exception ex){logger.Error("用户更新失败:" + user.sAMAccountName + ex.Message);}}/// <summary>/// 根据用户帐号称取得用户的 对象/// </summary>/// <param name="sAMAccountName">用户帐号名</param>/// <returns>如果找到该用户,则返回用户的 对象;否则返回 null</returns>public  DirectoryEntry GetDirectoryEntryByAccount(string sAMAccountName,ADInfo ad){DirectoryEntry de = GetDirectoryObject(ad);DirectorySearcher deSearch = new DirectorySearcher(de);//  DirectoryEntry de = new DirectoryEntry(path, adminUser, adminPwd, AuthenticationTypes.Secure);deSearch.Filter = "(&(&(objectCategory=person)(objectClass=user))(sAMAccountName=" + sAMAccountName + "))";deSearch.SearchScope = SearchScope.Subtree;try{SearchResult result = deSearch.FindOne();de = new DirectoryEntry(result.Path, ad.adminUser, ad.adminPwd);return de;}catch (Exception ex){return null;}}/// <summary>/// 根据用户帐号称取得用户的 对象/// </summary>/// <param name="sAMAccountName">用户帐号名</param>/// <returns>如果找到该用户,则返回用户的 对象;否则返回 null</returns>public string GetDirectoryPathEntryByAccount(string sAMAccountName, ADInfo ad){DirectoryEntry de = GetDirectoryObject(ad);DirectorySearcher deSearch = new DirectorySearcher(de);string path="";//  DirectoryEntry de = new DirectoryEntry(path, adminUser, adminPwd, AuthenticationTypes.Secure);deSearch.Filter = "(&(&(objectCategory=person)(objectClass=user))(sAMAccountName=" + sAMAccountName + "))";deSearch.SearchScope = SearchScope.Subtree;try{SearchResult result = deSearch.FindOne();if (result != null){de = new DirectoryEntry(result.Path, ad.adminUser, ad.adminPwd);path = de.Path;}return path;}catch (Exception ex){return "";}}/// <summary>/// 根据ou 路径 取得ou下所有用户/// </summary>/// <param name="sAMAccountName">用户帐号名</param>/// <returns>如果找到该用户,则返回用户的 对象;否则返回 null</returns>public List<DirectoryEntry> GetListDirectory(string path,ADInfo ad){List<DirectoryEntry> lis = new List<DirectoryEntry>();DirectoryEntry de = GetDirectoryObject(path, ad);DirectorySearcher deSearch = new DirectorySearcher(de);deSearch.Filter = "(&(objectCategory=person)(cn=*))";deSearch.SearchScope = SearchScope.Subtree;try{SearchResultCollection resultList = deSearch.FindAll();if (resultList != null && resultList.Count>0)foreach (SearchResult item in resultList){de = new DirectoryEntry(item.Path, ad.adminUser, ad.adminPwd);lis.Add(de);}return lis;}catch (Exception ex){return null;}}/// <summary>/// /// </summary>/// <param name="path"></param>/// <returns></returns>public DirectoryEntry GetOuDirectory(string attribute,ADInfo ad){DirectoryEntry ret = new DirectoryEntry();DirectoryEntry de = GetDirectoryObject(ad);DirectorySearcher deSearch = new DirectorySearcher(de);deSearch.Filter = "(&(objectCategory=organizationalUnit)(postalCode=" + attribute + "))";deSearch.SearchScope = SearchScope.Subtree;try{SearchResult resultList = deSearch.FindOne();ret = new DirectoryEntry(resultList.Path, ad.adminUser, ad.adminPwd);return ret;}catch (Exception ex){return null;}}#region 判断域中是否存在组织单位/// <summary>/// 判断域中是否存在组织单位/// </summary>/// <param name="organizeName">组织单位名</param>/// <returns></returns>private bool ExitOU(string organizeName,ADInfo ad){DirectoryEntry rootUser = null;DirectoryEntry ouFind = null;if (string.IsNullOrEmpty(organizeName)){return true;}else{//分解路径string[] allOu = organizeName.Split(new char[] { '/' });//获取直属部门string OUName = allOu[0].ToString();try{string path = GetOrganizeNamePath(organizeName, ad);rootUser = new DirectoryEntry(path, ad.adminUser, ad.adminPwd, AuthenticationTypes.Secure);ouFind = rootUser.Parent.Children.Find("OU=" + OUName);if (ouFind != null){return true;}return false;}catch (Exception ex){//DomainUser._failed = ex.Message.ToString() + "在域中不存在组织单位“" + OUName + "”";return false;}}}/// <summary>/// 是否村在OU路径/// </summary>/// <param name="path"></param>/// <returns></returns>public bool IsExistOuPath(string path,ADInfo ad) {DirectoryEntry rootUser = null;DirectoryEntry ouFind = null;rootUser = new DirectoryEntry(path, ad.adminUser, ad.adminPwd, AuthenticationTypes.Secure);if (rootUser != null){return true;}return false;}#endregion#region 获取组织名称路径/// <summary>/// 获取组织名称路径/// </summary>/// <param name="organizeUnit">组织</param>/// <returns></returns>public string GetOrganizeNamePath(string organizeUnit,ADInfo ad, string userName = null){StringBuilder sb = new StringBuilder();sb.Append(ad.ldapIdentity);return sb.Append(SplitOrganizeNameToDN(organizeUnit, ad,userName)).ToString();}#endregion#region 分隔组织名称为标准AD的DN名称/// <summary>/// 分隔组织名称为标准AD的DN名称,各个组织级别以"/"或"\"分开。如"总部/物业公司/小区",并且当前域为/// bdxy.com,则返回的AD的DN表示名为"OU=小区,OU=物业公司,OU=总部,DC=bdxy,DC=com"。 /// </summary>/// <param name="organizeName">组织名称</param>/// <returns>返回一个级别</returns>public string SplitOrganizeNameToDN(string organizeName, ADInfo ad, string userName = null){StringBuilder sb = new StringBuilder();if (userName != null){sb.Append("CN=" + userName);}if (organizeName != null && organizeName.Length > 0){string[] allOu = organizeName.Split(new char[] { '/', '\\' });for (int i = 0; i <= allOu.Length - 1; i++){string ou = allOu[i];if (sb.Length > 0){sb.Append(",");}sb.Append("OU=").Append(ou);}}//如果传入了组织名称,则添加,if (sb.Length > 0){sb.Append(",");}sb.Append(ad.suffixPath);return sb.ToString();}#endregion#region GetDirectoryObject/// <summary>/// 获得DirectoryEntry对象实例,以管理员登陆AD/// </summary>/// <returns></returns>private DirectoryEntry GetDirectoryObject(ADInfo ad){DirectoryEntry entry = new DirectoryEntry(ad.ldapIdentity+ad.suffixPath, ad.adminUser, ad.adminPwd, AuthenticationTypes.Secure);return entry;}/// <summary>/// 根据指定用户名和密码获得相应DirectoryEntry实体/// </summary>/// <param name="userName"></param>/// <param name="password"></param>/// <returns></returns>//private  DirectoryEntry GetDirectoryObject(string userName, string password)//{//    DirectoryEntry entry = new DirectoryEntry(_ldapIdentity,//        userName, password, AuthenticationTypes.None);//    return entry;//}/// <summary>/// i.e. /CN=Users,DC=creditsights, DC=cyberelves, DC=Com/// </summary>/// <param name="domainReference"></param>/// <returns></returns>private  DirectoryEntry GetDirectoryObject(string domainReference,ADInfo ad){DirectoryEntry entry = new DirectoryEntry(domainReference, ad.adminUser, ad.adminPwd,AuthenticationTypes.Secure);return entry;}/// <summary>///  获得以UserName,Password创建的DirectoryEntry/// </summary>/// <param name="domainReference"></param>/// <param name="userName"></param>/// <param name="password"></param>/// <returns></returns>//private  DirectoryEntry GetDirectoryObject(string domainReference,//    string userName, string password)//{//    DirectoryEntry entry = new DirectoryEntry(_ldapIdentity + domainReference,//        userName, password, AuthenticationTypes.Secure);//    return entry;//}#endregion/// <summary>///  判断帐户是否存在/// </summary>/// <param name="commonName">Account用户名</param>/// <returns>是否存在</returns>public bool IsAccExists(string sAMAccountName, ADInfo ad){DirectoryEntry de = GetDirectoryObject(ad);DirectorySearcher deSearch = new DirectorySearcher(de);deSearch.Filter = "(&(&(objectCategory=person)(objectClass=user))(sAMAccountName=" +sAMAccountName + "))";       // LDAP 查询串SearchResultCollection results = deSearch.FindAll();if (results.Count == 0)return false;elsereturn true;}public bool IsAccExistsCN(string sAMAccountName, ADInfo ad){DirectoryEntry de = GetDirectoryObject(ad);DirectorySearcher deSearch = new DirectorySearcher(de);deSearch.Filter = "(&(&(objectCategory=person)(objectClass=user))(CN=" +sAMAccountName + "))";       // LDAP 查询串SearchResultCollection results = deSearch.FindAll();if (results.Count == 0)return false;elsereturn true;}}public class DomainUser{public string UserName { get; set; }public string UserPrincipalName { get; set; }public string UserId { get; set; }public string PhysicalDeliveryOfficeName { get; set; }public string Department { get; set; }public string Telephone { get; set; }public string Email { get; set; }public string Description { get; set; }public string UserPwd { get; set; }}public class EmpInfo {public  string emloyeeID { get; set; } public  string sAMAccountName { get; set; }public  string userPrincipalName { get; set; }public  string employeeType { get; set; }public  string DepartmentName { get; set; }public  string Mail { get; set; }public  string DisplayName { get; set; }public  string Surname { get; set; }public  string GivenName { get; set; }public  string Department { get; set; }public string Oupath { get; set; }}public class ADInfo{public  string domain { get; set; } public  string domainIp { get; set; }public  string adminUser { get; set; } public  string adminPwd { get; set; }public  string ldapIdentity { get; set; } public  string suffixPath { get; set; }public string adsur { get; set; }public string houzhui { get; set; }public string dbCon { get; set; }}public class PingYinHelper{private static Encoding gb2312 = Encoding.GetEncoding("GB2312");/// <summary>/// 汉字转全拼/// </summary>/// <param name="strChinese"></param>/// <returns></returns>public static string ConvertToAllSpell(string strChinese){try{if (strChinese.Length != 0){StringBuilder fullSpell = new StringBuilder();for (int i = 0; i < strChinese.Length; i++){var chr = strChinese[i];fullSpell.Append(GetSpell(chr));}return fullSpell.ToString().ToUpper();}}catch (Exception e){Console.WriteLine("全拼转化出错!" + e.Message);}return string.Empty;}/// <summary>/// 汉字转首字母/// </summary>/// <param name="strChinese"></param>/// <returns></returns>public static string GetFirstSpell(string strChinese){//NPinyin.Pinyin.GetInitials(strChinese)  有Bug  洺无法识别//return NPinyin.Pinyin.GetInitials(strChinese);try{if (strChinese.Length != 0){StringBuilder fullSpell = new StringBuilder();for (int i = 0; i < strChinese.Length; i++){var chr = strChinese[i];fullSpell.Append(GetSpell(chr)[0]);}return fullSpell.ToString().ToUpper();}}catch (Exception e){Console.WriteLine("首字母转化出错!" + e.Message);}return string.Empty;}private static string GetSpell(char chr){var coverchr = NPinyin.Pinyin.GetPinyin(chr);bool isChineses = ChineseChar.IsValidChar(coverchr[0]);if (isChineses){ChineseChar chineseChar = new ChineseChar(coverchr[0]);foreach (string value in chineseChar.Pinyins){if (!string.IsNullOrEmpty(value)){return value.Remove(value.Length - 1, 1);}}}return coverchr;}}
}

 

查看全文
如若内容造成侵权/违法违规/事实不符,请联系编程学习网邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!

相关文章

  1. git error: RPC failed; curl 56 GnuTLS recv error 解决方案

    git error: RPC failed; curl 56 GnuTLS recv error 解决方案参考文章&#xff1a; &#xff08;1&#xff09;git error: RPC failed; curl 56 GnuTLS recv error 解决方案 &#xff08;2&#xff09;https://www.cnblogs.com/sddai/p/10209121.html 备忘一下。...

    2024/3/1 5:38:21
  2. 【Redis】Redis里面的key和value保存的内容是什么?

    我之前自己做了一个仿天猫的网站设计&#xff0c;有一次面试的时候就被问道&#xff1a;你的redis里面的key是怎么设置的&#xff0c;value里面的内容又是什么&#xff1f;因为时间隔了比较久&#xff0c;忘得差不多了&#xff0c;今天刚好回忆并总结一下&#xff0c;以防下次被…...

    2024/3/29 10:38:38
  3. 挑战全网,突击并发编程JUC系列-并发工具 CyclicBarrier,不信有人讲的比我好

    俗话说趁热要打铁,上篇中介绍的 CountDownLatch 的基本用法&#xff0c; CountDownLatch 计数器是一次性的&#xff0c;也就是等到计数器值变为0后&#xff0c;再调用CountDownLatch的await和countdown方法都会立刻返回&#xff0c;这就起不到线程同步的效果了。 对于部分业务需…...

    2024/3/26 11:00:44
  4. C++ 学习之旅(11)——类和结构中的static

    当我们使用 static 关键字来把类或者结构成员定义为静态的时侯&#xff0c;无论之后创建多少个类的对象&#xff08;实例&#xff09;&#xff0c;静态成员都只有一个副本&#xff0c;所有实例都共享这个副本。也就是说&#xff0c;静态成员已经不属于实例了&#xff0c;它归属…...

    2024/3/18 8:54:18
  5. Linux 服务器拷贝远程文件 SCP

    1.复制文件 &#xff08;1&#xff09;将本地文件拷贝到远程 &#xff08;有时候权限不允许&#xff09; scp 文件名 用户名计算机IP或者计算机名称:远程路径 scp /root/install.* root192.168.1.12:/usr/local/src&#xff08;2&#xff09;从远程将文件拷回本地 scp 用户名…...

    2024/2/29 22:12:31
  6. 阿里云二级域名解析到指定端口号的一种方法

    文章目录添加域名第一个中转域名第二个真正访问的子域名结果添加域名 阿里云的域名解析中有 可以添加两条记录&#xff0c;实现二级域名指定端口号 第一个中转域名 第二个真正访问的子域名 结果 这样就可以直接访问ab.XXX.com&#xff0c;会自动跳转到指定的http://IP:端口…...

    2024/3/18 15:01:44
  7. VMware虚拟机中如何配置ip地址网关和dns

    创建虚拟机之后给虚拟机配置ip以及dns ONBOOT&#xff1a;开机启动。 NM_CONTROLLED&#xff1a;网络管理组件是否启用&#xff0c;精简版的是没有这个组件的。所以就不需要开启。 BOOTPROTO&#xff1a;dhcp 静态为static。 IPPADDR&#xff1a;手动指定ip地址。 NETMASK…...

    2024/2/28 12:52:57
  8. 关于Java中的多模块项目设计思考

    前段时间从朋友那里拿到了一套破解版禾匠小程序源码。部署到服务器上面看了一下&#xff0c;确实不错&#xff0c;作为电商平台进销存营销等该有的功能都有&#xff0c;而且还有丰富的付费插件供用户付费开通。作为java开发&#xff0c;有些功能的实现方式在java的系统开发中不…...

    2024/3/6 22:38:10
  9. 趣谈网络协议!华为18级技术大牛呕心沥血终成545页神仙文档!

    网络是用物理链路将各个孤立的工作站或主机相连在一起&#xff0c;组成数据链路&#xff0c;从而达到资源共享和通信的目的。通信是人与人之间通过某种媒体进行的信息交流与传递。网络通信是通过网络将各个孤立的设备进行连接&#xff0c;通过信息交换实现人与人&#xff0c;人…...

    2024/3/1 0:54:19
  10. 分享一下我的Python自学历程,分享下我自己学习方法【实用】

    其实关于编程这事儿没有接触的那么早&#xff0c;大一的时候没什么关注点&#xff0c;有一门课是vb&#xff0c;一天天的&#xff0c;就抄抄作业啥的就完事儿了。当时也觉的自己不是学编程的料&#xff0c;想着以后估摸也不会干开发相关的工作。 我的自学历程 阴差阳错的进入到…...

    2024/2/29 16:37:58
  11. CTFSHOW-WEB入门 writeup

    web1 题目&#xff1a; 开发注释未及时删除 解题思路&#xff1a; 右键查看源代码即可得到flag。 web2 题目&#xff1a; js前台拦截 无效操作 解题思路&#xff1a; 火狐浏览器禁止JavaScript之后&#xff0c;右键查看源代码&#xff0c;得到flag。 web3 题目&#xff1…...

    2024/2/29 16:37:58
  12. 6、封装详解

    转载请注明出处 --爱技术的华仔&#xff08;http://blog.csdn.net/yunhua_lee&#xff09; 封装的概念本身很好理解&#xff0c;意思就是把一堆东东装起来。 但要想真正理解封装&#xff0c;这样还远远不够。 第一个问题是&#xff1a;我们要封装什么&#xff1f; 这个问题很…...

    2024/1/28 12:35:07
  13. zxing(二维码生成与读取)

    1. maven <dependency><groupId>com.google.zxing</groupId><artifactId>core</artifactId><version>3.3.0</version></dependency><!-- 如果是 web 应用添加--><dependency><groupId>com.google.zx…...

    2024/3/20 9:29:33
  14. 深入浅出FaaS应用场景:数据编排

    通过上一篇深入浅出FaaS的两种进程模型了解到FaaS 的进程模型有两种&#xff1a;常驻进程型和用完即毁型。常驻进程型是为了适应传统 MVC 架构设计的&#xff0c;它看起来并不自然&#xff1b;如果你从现在开始玩 FaaS 的话&#xff0c;我当然首选推荐用完即毁型&#xff0c;它…...

    2024/2/21 9:39:57
  15. 气动调节蝶阀小知识!

    嗨&#xff0c;你们的工控小管家回来啦&#xff0c;今天我们带来了气动调节阀的小知识&#xff0c;一起学习吧。 气动调节蝶阀是一种&#xff08;阀板&#xff09;绕垂直于通道的固定轴旋转的阀门&#xff0c;其由活塞式双作用或单作用&#xff08;弹簧复位式&#xff09;气动…...

    2024/2/29 16:37:58
  16. 生产环境OOM问题

    这里写自定义目录标题问题描述&#xff1a;产生如下异常 java.lang.OutOfMemoryError: GC overhead limit exceeded Sun 官方对此的定义&#xff1a;超过98%的时间用来做GC并且回收了不到2%的堆内存时会抛出此异常。 【现象】如下图所示 打开Visual GC 查看JVM各个内存区的占用…...

    2024/3/29 7:56:54
  17. 分享一下我的Python自学历程,分享下我自己学习方法

    其实关于编程这事儿没有接触的那么早&#xff0c;大一的时候没什么关注点&#xff0c;有一门课是vb&#xff0c;一天天的&#xff0c;就抄抄作业啥的就完事儿了。当时也觉的自己不是学编程的料&#xff0c;想着以后估摸也不会干开发相关的工作。 我的自学历程 阴差阳错的进入到…...

    2024/3/16 0:05:25
  18. 爬虫--破解验证码的几种方式

    1.使用selenium 手动输入 2.使用打码平台(超级鹰http://www.chaojiying.com/price.html)推荐 3.机器学习 去第三方打码平台注册账号(超级鹰),拿到Python的接口压缩包 #!/usr/bin/env python # coding:utf-8import requests from hashlib import md5class Chaojiying_Client(o…...

    2024/3/14 9:39:19
  19. centos linux系统后门程序

    centos linux系统后门程序 编译/root/autorunp.c木马gcc -o autorunp autorunp.c给程序提权chmod x或者chmod 777运行./autoeunp.c修改成系统启动后自动卸载 的修改文件路径/etc/rc.local远程打开/bin/sh运行查看ip地址的命令字符串/sbin/ifconfig阻止对centos5.5进行超级管理员…...

    2024/3/21 11:07:09
  20. GPU 上的纹理性能优化实例

    片段着色器最重要的任务就是从纹理当中获取和过滤像素值。 与其相关的 GPU 性能指标可以被总结为三类: 带宽缓存行为(cache behaviour)滤波(filtering)举个栗子 以某一个游戏为例,如图 带宽 为了确保传输给 GPU 的纹理数据不会超过一定的带宽限制,它的均值就不宜超…...

    2024/3/5 2:46:27

最新文章

  1. 刷题之动态规划

    前言 大家好&#xff0c;我是jiantaoyab&#xff0c;开始刷动态规划的题目了&#xff0c;要特别注意初始化的时候给什么值。 动态规划5个步骤 状态表示 &#xff1a;dp数组中每一个下标对应值的含义是什么->dp[i]表示什么状态转移方程&#xff1a; dp[i] 等于什么1 和 2 是…...

    2024/3/29 12:56:32
  2. 梯度消失和梯度爆炸的一些处理方法

    在这里是记录一下梯度消失或梯度爆炸的一些处理技巧。全当学习总结了如有错误还请留言&#xff0c;在此感激不尽。 权重和梯度的更新公式如下&#xff1a; w w − η ⋅ ∇ w w w - \eta \cdot \nabla w ww−η⋅∇w 个人通俗的理解梯度消失就是网络模型在反向求导的时候出…...

    2024/3/20 10:50:27
  3. [机缘参悟-162/管理者与领导者-151] :受害者心态与受害者思维模式,如何克服受害者思维模式,管理者如何管理这种思维模式的人?

    目录 一、受害者心态概述 1.1 什么是受害者心态 1.2 受害者心态的表现形式 1.3 受害者心态在职场上的表现 1.4 受害者思维模式 1.5 受害者心态的危害 二、受害者心态的成因 2.1 概述 2.2 神经网络与受害者心态 三、如何克服受害者心态 3.1 概述 3.2 职场 3.3 家庭…...

    2024/3/29 12:13:17
  4. Unity 布局元素Layout Element

    Layout Element是一种用于控制UI元素在布局组件&#xff08;如Horizontal Layout Group、Vertical Layout Group、Grid Layout Group、Content Size Fitter和Aspect Ratio Fitter&#xff09;中的大小和位置的组件。Layout Element组件可以附加到UI元素上&#xff0c;以便在布局…...

    2024/3/29 1:00:11
  5. 抖音IP属地怎么更改

    抖音是一个非常受欢迎的短视频平台&#xff0c;吸引了无数用户在上面分享自己的生活和才艺。然而&#xff0c;随着快手的火爆&#xff0c;一些用户开始担心自己的IP地址会被他人获取&#xff0c;引起个人隐私风险。那么&#xff0c;抖音用户又该如何更改到别的地方呢&#xff1…...

    2024/3/27 22:13:54
  6. 416. 分割等和子集问题(动态规划)

    题目 题解 class Solution:def canPartition(self, nums: List[int]) -> bool:# badcaseif not nums:return True# 不能被2整除if sum(nums) % 2 ! 0:return False# 状态定义&#xff1a;dp[i][j]表示当背包容量为j&#xff0c;用前i个物品是否正好可以将背包填满&#xff…...

    2024/3/28 16:59:55
  7. 【Java】ExcelWriter自适应宽度工具类(支持中文)

    工具类 import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet;/*** Excel工具类** author xiaoming* date 2023/11/17 10:40*/ public class ExcelUti…...

    2024/3/28 4:39:34
  8. Spring cloud负载均衡@LoadBalanced LoadBalancerClient

    LoadBalance vs Ribbon 由于Spring cloud2020之后移除了Ribbon&#xff0c;直接使用Spring Cloud LoadBalancer作为客户端负载均衡组件&#xff0c;我们讨论Spring负载均衡以Spring Cloud2020之后版本为主&#xff0c;学习Spring Cloud LoadBalance&#xff0c;暂不讨论Ribbon…...

    2024/3/28 5:03:31
  9. TSINGSEE青犀AI智能分析+视频监控工业园区周界安全防范方案

    一、背景需求分析 在工业产业园、化工园或生产制造园区中&#xff0c;周界防范意义重大&#xff0c;对园区的安全起到重要的作用。常规的安防方式是采用人员巡查&#xff0c;人力投入成本大而且效率低。周界一旦被破坏或入侵&#xff0c;会影响园区人员和资产安全&#xff0c;…...

    2024/3/28 19:59:46
  10. VB.net WebBrowser网页元素抓取分析方法

    在用WebBrowser编程实现网页操作自动化时&#xff0c;常要分析网页Html&#xff0c;例如网页在加载数据时&#xff0c;常会显示“系统处理中&#xff0c;请稍候..”&#xff0c;我们需要在数据加载完成后才能继续下一步操作&#xff0c;如何抓取这个信息的网页html元素变化&…...

    2024/3/28 21:57:52
  11. 【Objective-C】Objective-C汇总

    方法定义 参考&#xff1a;https://www.yiibai.com/objective_c/objective_c_functions.html Objective-C编程语言中方法定义的一般形式如下 - (return_type) method_name:( argumentType1 )argumentName1 joiningArgument2:( argumentType2 )argumentName2 ... joiningArgu…...

    2024/3/28 9:07:44
  12. 【洛谷算法题】P5713-洛谷团队系统【入门2分支结构】

    &#x1f468;‍&#x1f4bb;博客主页&#xff1a;花无缺 欢迎 点赞&#x1f44d; 收藏⭐ 留言&#x1f4dd; 加关注✅! 本文由 花无缺 原创 收录于专栏 【洛谷算法题】 文章目录 【洛谷算法题】P5713-洛谷团队系统【入门2分支结构】&#x1f30f;题目描述&#x1f30f;输入格…...

    2024/3/28 18:09:48
  13. 【ES6.0】- 扩展运算符(...)

    【ES6.0】- 扩展运算符... 文章目录 【ES6.0】- 扩展运算符...一、概述二、拷贝数组对象三、合并操作四、参数传递五、数组去重六、字符串转字符数组七、NodeList转数组八、解构变量九、打印日志十、总结 一、概述 **扩展运算符(...)**允许一个表达式在期望多个参数&#xff0…...

    2024/3/28 21:57:50
  14. 摩根看好的前智能硬件头部品牌双11交易数据极度异常!——是模式创新还是饮鸩止渴?

    文 | 螳螂观察 作者 | 李燃 双11狂欢已落下帷幕&#xff0c;各大品牌纷纷晒出优异的成绩单&#xff0c;摩根士丹利投资的智能硬件头部品牌凯迪仕也不例外。然而有爆料称&#xff0c;在自媒体平台发布霸榜各大榜单喜讯的凯迪仕智能锁&#xff0c;多个平台数据都表现出极度异常…...

    2024/3/29 10:46:22
  15. Go语言常用命令详解(二)

    文章目录 前言常用命令go bug示例参数说明 go doc示例参数说明 go env示例 go fix示例 go fmt示例 go generate示例 总结写在最后 前言 接着上一篇继续介绍Go语言的常用命令 常用命令 以下是一些常用的Go命令&#xff0c;这些命令可以帮助您在Go开发中进行编译、测试、运行和…...

    2024/3/28 10:24:59
  16. 用欧拉路径判断图同构推出reverse合法性:1116T4

    http://cplusoj.com/d/senior/p/SS231116D 假设我们要把 a a a 变成 b b b&#xff0c;我们在 a i a_i ai​ 和 a i 1 a_{i1} ai1​ 之间连边&#xff0c; b b b 同理&#xff0c;则 a a a 能变成 b b b 的充要条件是两图 A , B A,B A,B 同构。 必要性显然&#xff0…...

    2024/3/28 19:51:36
  17. 【NGINX--1】基础知识

    1、在 Debian/Ubuntu 上安装 NGINX 在 Debian 或 Ubuntu 机器上安装 NGINX 开源版。 更新已配置源的软件包信息&#xff0c;并安装一些有助于配置官方 NGINX 软件包仓库的软件包&#xff1a; apt-get update apt install -y curl gnupg2 ca-certificates lsb-release debian-…...

    2024/3/28 19:36:32
  18. Hive默认分割符、存储格式与数据压缩

    目录 1、Hive默认分割符2、Hive存储格式3、Hive数据压缩 1、Hive默认分割符 Hive创建表时指定的行受限&#xff08;ROW FORMAT&#xff09;配置标准HQL为&#xff1a; ... ROW FORMAT DELIMITED FIELDS TERMINATED BY \u0001 COLLECTION ITEMS TERMINATED BY , MAP KEYS TERMI…...

    2024/3/28 17:15:47
  19. 【论文阅读】MAG:一种用于航天器遥测数据中有效异常检测的新方法

    文章目录 摘要1 引言2 问题描述3 拟议框架4 所提出方法的细节A.数据预处理B.变量相关分析C.MAG模型D.异常分数 5 实验A.数据集和性能指标B.实验设置与平台C.结果和比较 6 结论 摘要 异常检测是保证航天器稳定性的关键。在航天器运行过程中&#xff0c;传感器和控制器产生大量周…...

    2024/3/29 9:27:12
  20. --max-old-space-size=8192报错

    vue项目运行时&#xff0c;如果经常运行慢&#xff0c;崩溃停止服务&#xff0c;报如下错误 FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory 因为在 Node 中&#xff0c;通过JavaScript使用内存时只能使用部分内存&#xff08;64位系统&…...

    2024/3/29 12:34:40
  21. 基于深度学习的恶意软件检测

    恶意软件是指恶意软件犯罪者用来感染个人计算机或整个组织的网络的软件。 它利用目标系统漏洞&#xff0c;例如可以被劫持的合法软件&#xff08;例如浏览器或 Web 应用程序插件&#xff09;中的错误。 恶意软件渗透可能会造成灾难性的后果&#xff0c;包括数据被盗、勒索或网…...

    2024/3/28 19:58:12
  22. JS原型对象prototype

    让我简单的为大家介绍一下原型对象prototype吧&#xff01; 使用原型实现方法共享 1.构造函数通过原型分配的函数是所有对象所 共享的。 2.JavaScript 规定&#xff0c;每一个构造函数都有一个 prototype 属性&#xff0c;指向另一个对象&#xff0c;所以我们也称为原型对象…...

    2024/3/28 21:57:45
  23. C++中只能有一个实例的单例类

    C中只能有一个实例的单例类 前面讨论的 President 类很不错&#xff0c;但存在一个缺陷&#xff1a;无法禁止通过实例化多个对象来创建多名总统&#xff1a; President One, Two, Three; 由于复制构造函数是私有的&#xff0c;其中每个对象都是不可复制的&#xff0c;但您的目…...

    2024/3/29 11:55:06
  24. python django 小程序图书借阅源码

    开发工具&#xff1a; PyCharm&#xff0c;mysql5.7&#xff0c;微信开发者工具 技术说明&#xff1a; python django html 小程序 功能介绍&#xff1a; 用户端&#xff1a; 登录注册&#xff08;含授权登录&#xff09; 首页显示搜索图书&#xff0c;轮播图&#xff0…...

    2024/3/29 8:23:18
  25. 电子学会C/C++编程等级考试2022年03月(一级)真题解析

    C/C++等级考试(1~8级)全部真题・点这里 第1题:双精度浮点数的输入输出 输入一个双精度浮点数,保留8位小数,输出这个浮点数。 时间限制:1000 内存限制:65536输入 只有一行,一个双精度浮点数。输出 一行,保留8位小数的浮点数。样例输入 3.1415926535798932样例输出 3.1…...

    2024/3/28 9:26:43
  26. 配置失败还原请勿关闭计算机,电脑开机屏幕上面显示,配置失败还原更改 请勿关闭计算机 开不了机 这个问题怎么办...

    解析如下&#xff1a;1、长按电脑电源键直至关机&#xff0c;然后再按一次电源健重启电脑&#xff0c;按F8健进入安全模式2、安全模式下进入Windows系统桌面后&#xff0c;按住“winR”打开运行窗口&#xff0c;输入“services.msc”打开服务设置3、在服务界面&#xff0c;选中…...

    2022/11/19 21:17:18
  27. 错误使用 reshape要执行 RESHAPE,请勿更改元素数目。

    %读入6幅图像&#xff08;每一幅图像的大小是564*564&#xff09; f1 imread(WashingtonDC_Band1_564.tif); subplot(3,2,1),imshow(f1); f2 imread(WashingtonDC_Band2_564.tif); subplot(3,2,2),imshow(f2); f3 imread(WashingtonDC_Band3_564.tif); subplot(3,2,3),imsho…...

    2022/11/19 21:17:16
  28. 配置 已完成 请勿关闭计算机,win7系统关机提示“配置Windows Update已完成30%请勿关闭计算机...

    win7系统关机提示“配置Windows Update已完成30%请勿关闭计算机”问题的解决方法在win7系统关机时如果有升级系统的或者其他需要会直接进入一个 等待界面&#xff0c;在等待界面中我们需要等待操作结束才能关机&#xff0c;虽然这比较麻烦&#xff0c;但是对系统进行配置和升级…...

    2022/11/19 21:17:15
  29. 台式电脑显示配置100%请勿关闭计算机,“准备配置windows 请勿关闭计算机”的解决方法...

    有不少用户在重装Win7系统或更新系统后会遇到“准备配置windows&#xff0c;请勿关闭计算机”的提示&#xff0c;要过很久才能进入系统&#xff0c;有的用户甚至几个小时也无法进入&#xff0c;下面就教大家这个问题的解决方法。第一种方法&#xff1a;我们首先在左下角的“开始…...

    2022/11/19 21:17:14
  30. win7 正在配置 请勿关闭计算机,怎么办Win7开机显示正在配置Windows Update请勿关机...

    置信有很多用户都跟小编一样遇到过这样的问题&#xff0c;电脑时发现开机屏幕显现“正在配置Windows Update&#xff0c;请勿关机”(如下图所示)&#xff0c;而且还需求等大约5分钟才干进入系统。这是怎样回事呢&#xff1f;一切都是正常操作的&#xff0c;为什么开时机呈现“正…...

    2022/11/19 21:17:13
  31. 准备配置windows 请勿关闭计算机 蓝屏,Win7开机总是出现提示“配置Windows请勿关机”...

    Win7系统开机启动时总是出现“配置Windows请勿关机”的提示&#xff0c;没过几秒后电脑自动重启&#xff0c;每次开机都这样无法进入系统&#xff0c;此时碰到这种现象的用户就可以使用以下5种方法解决问题。方法一&#xff1a;开机按下F8&#xff0c;在出现的Windows高级启动选…...

    2022/11/19 21:17:12
  32. 准备windows请勿关闭计算机要多久,windows10系统提示正在准备windows请勿关闭计算机怎么办...

    有不少windows10系统用户反映说碰到这样一个情况&#xff0c;就是电脑提示正在准备windows请勿关闭计算机&#xff0c;碰到这样的问题该怎么解决呢&#xff0c;现在小编就给大家分享一下windows10系统提示正在准备windows请勿关闭计算机的具体第一种方法&#xff1a;1、2、依次…...

    2022/11/19 21:17:11
  33. 配置 已完成 请勿关闭计算机,win7系统关机提示“配置Windows Update已完成30%请勿关闭计算机”的解决方法...

    今天和大家分享一下win7系统重装了Win7旗舰版系统后&#xff0c;每次关机的时候桌面上都会显示一个“配置Windows Update的界面&#xff0c;提示请勿关闭计算机”&#xff0c;每次停留好几分钟才能正常关机&#xff0c;导致什么情况引起的呢&#xff1f;出现配置Windows Update…...

    2022/11/19 21:17:10
  34. 电脑桌面一直是清理请关闭计算机,windows7一直卡在清理 请勿关闭计算机-win7清理请勿关机,win7配置更新35%不动...

    只能是等着&#xff0c;别无他法。说是卡着如果你看硬盘灯应该在读写。如果从 Win 10 无法正常回滚&#xff0c;只能是考虑备份数据后重装系统了。解决来方案一&#xff1a;管理员运行cmd&#xff1a;net stop WuAuServcd %windir%ren SoftwareDistribution SDoldnet start WuA…...

    2022/11/19 21:17:09
  35. 计算机配置更新不起,电脑提示“配置Windows Update请勿关闭计算机”怎么办?

    原标题&#xff1a;电脑提示“配置Windows Update请勿关闭计算机”怎么办&#xff1f;win7系统中在开机与关闭的时候总是显示“配置windows update请勿关闭计算机”相信有不少朋友都曾遇到过一次两次还能忍但经常遇到就叫人感到心烦了遇到这种问题怎么办呢&#xff1f;一般的方…...

    2022/11/19 21:17:08
  36. 计算机正在配置无法关机,关机提示 windows7 正在配置windows 请勿关闭计算机 ,然后等了一晚上也没有关掉。现在电脑无法正常关机...

    关机提示 windows7 正在配置windows 请勿关闭计算机 &#xff0c;然后等了一晚上也没有关掉。现在电脑无法正常关机以下文字资料是由(历史新知网www.lishixinzhi.com)小编为大家搜集整理后发布的内容&#xff0c;让我们赶快一起来看一下吧&#xff01;关机提示 windows7 正在配…...

    2022/11/19 21:17:05
  37. 钉钉提示请勿通过开发者调试模式_钉钉请勿通过开发者调试模式是真的吗好不好用...

    钉钉请勿通过开发者调试模式是真的吗好不好用 更新时间:2020-04-20 22:24:19 浏览次数:729次 区域: 南阳 > 卧龙 列举网提醒您:为保障您的权益,请不要提前支付任何费用! 虚拟位置外设器!!轨迹模拟&虚拟位置外设神器 专业用于:钉钉,外勤365,红圈通,企业微信和…...

    2022/11/19 21:17:05
  38. 配置失败还原请勿关闭计算机怎么办,win7系统出现“配置windows update失败 还原更改 请勿关闭计算机”,长时间没反应,无法进入系统的解决方案...

    前几天班里有位学生电脑(windows 7系统)出问题了&#xff0c;具体表现是开机时一直停留在“配置windows update失败 还原更改 请勿关闭计算机”这个界面&#xff0c;长时间没反应&#xff0c;无法进入系统。这个问题原来帮其他同学也解决过&#xff0c;网上搜了不少资料&#x…...

    2022/11/19 21:17:04
  39. 一个电脑无法关闭计算机你应该怎么办,电脑显示“清理请勿关闭计算机”怎么办?...

    本文为你提供了3个有效解决电脑显示“清理请勿关闭计算机”问题的方法&#xff0c;并在最后教给你1种保护系统安全的好方法&#xff0c;一起来看看&#xff01;电脑出现“清理请勿关闭计算机”在Windows 7(SP1)和Windows Server 2008 R2 SP1中&#xff0c;添加了1个新功能在“磁…...

    2022/11/19 21:17:03
  40. 请勿关闭计算机还原更改要多久,电脑显示:配置windows更新失败,正在还原更改,请勿关闭计算机怎么办...

    许多用户在长期不使用电脑的时候&#xff0c;开启电脑发现电脑显示&#xff1a;配置windows更新失败&#xff0c;正在还原更改&#xff0c;请勿关闭计算机。。.这要怎么办呢&#xff1f;下面小编就带着大家一起看看吧&#xff01;如果能够正常进入系统&#xff0c;建议您暂时移…...

    2022/11/19 21:17:02
  41. 还原更改请勿关闭计算机 要多久,配置windows update失败 还原更改 请勿关闭计算机,电脑开机后一直显示以...

    配置windows update失败 还原更改 请勿关闭计算机&#xff0c;电脑开机后一直显示以以下文字资料是由(历史新知网www.lishixinzhi.com)小编为大家搜集整理后发布的内容&#xff0c;让我们赶快一起来看一下吧&#xff01;配置windows update失败 还原更改 请勿关闭计算机&#x…...

    2022/11/19 21:17:01
  42. 电脑配置中请勿关闭计算机怎么办,准备配置windows请勿关闭计算机一直显示怎么办【图解】...

    不知道大家有没有遇到过这样的一个问题&#xff0c;就是我们的win7系统在关机的时候&#xff0c;总是喜欢显示“准备配置windows&#xff0c;请勿关机”这样的一个页面&#xff0c;没有什么大碍&#xff0c;但是如果一直等着的话就要两个小时甚至更久都关不了机&#xff0c;非常…...

    2022/11/19 21:17:00
  43. 正在准备配置请勿关闭计算机,正在准备配置windows请勿关闭计算机时间长了解决教程...

    当电脑出现正在准备配置windows请勿关闭计算机时&#xff0c;一般是您正对windows进行升级&#xff0c;但是这个要是长时间没有反应&#xff0c;我们不能再傻等下去了。可能是电脑出了别的问题了&#xff0c;来看看教程的说法。正在准备配置windows请勿关闭计算机时间长了方法一…...

    2022/11/19 21:16:59
  44. 配置失败还原请勿关闭计算机,配置Windows Update失败,还原更改请勿关闭计算机...

    我们使用电脑的过程中有时会遇到这种情况&#xff0c;当我们打开电脑之后&#xff0c;发现一直停留在一个界面&#xff1a;“配置Windows Update失败&#xff0c;还原更改请勿关闭计算机”&#xff0c;等了许久还是无法进入系统。如果我们遇到此类问题应该如何解决呢&#xff0…...

    2022/11/19 21:16:58
  45. 如何在iPhone上关闭“请勿打扰”

    Apple’s “Do Not Disturb While Driving” is a potentially lifesaving iPhone feature, but it doesn’t always turn on automatically at the appropriate time. For example, you might be a passenger in a moving car, but your iPhone may think you’re the one dri…...

    2022/11/19 21:16:57