![使用批量修改域帳戶信息全部代碼_第1頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2022-1/10/7b9c6917-9eb9-4b9d-976d-a5a150ad182f/7b9c6917-9eb9-4b9d-976d-a5a150ad182f1.gif)
![使用批量修改域帳戶信息全部代碼_第2頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2022-1/10/7b9c6917-9eb9-4b9d-976d-a5a150ad182f/7b9c6917-9eb9-4b9d-976d-a5a150ad182f2.gif)
![使用批量修改域帳戶信息全部代碼_第3頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2022-1/10/7b9c6917-9eb9-4b9d-976d-a5a150ad182f/7b9c6917-9eb9-4b9d-976d-a5a150ad182f3.gif)
![使用批量修改域帳戶信息全部代碼_第4頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2022-1/10/7b9c6917-9eb9-4b9d-976d-a5a150ad182f/7b9c6917-9eb9-4b9d-976d-a5a150ad182f4.gif)
![使用批量修改域帳戶信息全部代碼_第5頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2022-1/10/7b9c6917-9eb9-4b9d-976d-a5a150ad182f/7b9c6917-9eb9-4b9d-976d-a5a150ad182f5.gif)
版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、使用使用 C#C#批量修改域帳戶信息全部代碼批量修改域帳戶信息全部代碼本文關(guān)鍵字:本文關(guān)鍵字:using System;using System.Drawing;using System.Collections;using System.ComponentModel;using System.Windows.Forms;using System.Data;using System.DirectoryServices;namespace change/ / Form1 的摘要說(shuō)明。/ public class Form1 : System.Windows.Forms.Formprivate Sy
2、stem.Windows.Forms.ComboBox comboBox2;private System.Windows.Forms.Label label3;private System.Windows.Forms.ComboBox comboBox1;private System.Windows.Forms.Label label2;string str=;string strErr=;string strManager=;private System.Windows.Forms.Label label1;private System.Windows.Forms.Label label4;
3、private System.Windows.Forms.Button button1;private System.Windows.Forms.TextBox textBox1;private System.Windows.Forms.TextBox textBox2;private System.Windows.Forms.TextBox textBox3;private System.Windows.Forms.CheckBox checkBox1;private System.Windows.Forms.CheckBox checkBox2;private System.Windows
4、.Forms.CheckBox checkBox3;private System.Windows.Forms.Label label5;private System.Windows.Forms.TextBox textBox4;private System.Windows.Forms.ComboBox comboBox3;private System.Windows.Forms.Label label6;private System.Windows.Forms.ComboBox comboBox4;private System.Windows.Forms.Label label7;privat
5、e System.Windows.Forms.ComboBox comboBox5;private System.Windows.Forms.Label label8;private System.Windows.Forms.ComboBox comboBox6;private System.Windows.Forms.Label label9;/ / 必需的設(shè)計(jì)器變量。/ private System.ComponentModel.Container components = null;public Form1()/ Windows 窗體設(shè)計(jì)器支持所必需的/InitializeCompone
6、nt();/ TODO: 在 InitializeComponent 調(diào)用后添加任何構(gòu)造函數(shù)代碼/ / 清理所有正在使用的資源。/ protected override void Dispose( bool disposing )if( disposing )if (components != null)components.Dispose();歡迎光臨八一學(xué)習(xí)網(wǎng)八一學(xué)習(xí)網(wǎng),收藏本篇文章收藏本篇文章$False$base.Dispose( disposing );#region Windows 窗體設(shè)計(jì)器生成的代碼/ / 設(shè)計(jì)器支持所需的方法 - 不要使用代碼編輯器修改/ 此方法的內(nèi)容。/ p
7、rivate void InitializeComponent()boBox2 = new System.Windows.Forms.ComboBox();this.label3 = new System.Windows.Forms.Label();boBox1 = new System.Windows.Forms.ComboBox();this.label2 = new System.Windows.Forms.Label();this.label1 = new System.Windows.Forms.Label();this.label4 = new System.Windows.For
8、ms.Label();this.button1 = new System.Windows.Forms.Button();this.textBox1 = new System.Windows.Forms.TextBox();this.textBox2 = new System.Windows.Forms.TextBox();this.textBox3 = new System.Windows.Forms.TextBox();this.checkBox1 = new System.Windows.Forms.CheckBox();this.checkBox2 = new System.Window
9、s.Forms.CheckBox();this.checkBox3 = new System.Windows.Forms.CheckBox();this.label5 = new System.Windows.Forms.Label();this.textBox4 = new System.Windows.Forms.TextBox();boBox3 = new System.Windows.Forms.ComboBox();this.label6 = new System.Windows.Forms.Label();boBox4 = new System.Windows.Forms.Comb
10、oBox();this.label7 = new System.Windows.Forms.Label();boBox5 = new System.Windows.Forms.ComboBox();this.label8 = new System.Windows.Forms.Label();boBox6 = new System.Windows.Forms.ComboBox();this.label9 = new System.Windows.Forms.Label();this.SuspendLayout();/ comboBox2/boBox2.Location = new System.
11、Drawing.Point(416, 16);boBox2.Name = comboBox2;boBox2.Size = new System.Drawing.Size(121, 20);boBox2.TabIndex = 10;boBox2.SelectedIndexChanged += newSystem.EventHandler(boBox2_SelectedIndexChanged);/ label3/this.label3.Location = new System.Drawing.Point(320, 20);this.label3.Name = label3;this.label
12、3.Size = new System.Drawing.Size(80, 16);this.label3.TabIndex = 9;this.label3.Text = 文章整理文章整理: :八一學(xué)習(xí)網(wǎng)八一學(xué)習(xí)網(wǎng) http:/http:/ (本站)選擇部門(OU);/ comboBox1/boBox1.Location = new System.Drawing.Point(144, 16);boBox1.Name = comboBox1;boBox1.Size = new System.Drawing.Size(121, 20);boBox1.TabIndex = 8;boBox1.Selec
13、tedIndexChanged += newSystem.EventHandler(boBox1_SelectedIndexChanged);本文關(guān)鍵字:本文關(guān)鍵字:/ label2/this.label2.AutoSize = true;this.label2.Location = new System.Drawing.Point(40, 19);this.label2.Name = label2;this.label2.Size = new System.Drawing.Size(79, 17);this.label2.TabIndex = 7;this.label2.Text = 選擇公
14、司(OU);/ label1/this.label1.Location = new System.Drawing.Point(48, 128);this.label1.Name = label1;this.label1.Size = new System.Drawing.Size(72, 23);this.label1.TabIndex = 11; this.label1.Text = 新公司名稱;/ label4/this.label4.Location = new System.Drawing.Point(328, 128);this.label4.Name = label4;this.l
15、abel4.Size = new System.Drawing.Size(72, 23);this.label4.TabIndex = 12;this.label4.Text = 新部門名稱;/ button1/this.button1.Location = new System.Drawing.Point(376, 376);this.button1.Name = button1;this.button1.TabIndex = 15;this.button1.Text = 開(kāi)始處理;this.button1.Click += new System.EventHandler(this.butt
16、on1_Click);/ textBox1/this.textBox1.Location = new System.Drawing.Point(144, 128);this.textBox1.Name = textBox1;this.textBox1.Size = new System.Drawing.Size(120, 21);this.textBox1.TabIndex = 16;this.textBox1.Text = ;/ textBox2/this.textBox2.Location = new System.Drawing.Point(416, 128);this.textBox2
17、.Name = textBox2;this.textBox2.Size = new System.Drawing.Size(120, 21);this.textBox2.TabIndex = 17;this.textBox2.Text = ;/ textBox3/ 歡迎光臨八一學(xué)習(xí)網(wǎng)八一學(xué)習(xí)網(wǎng),點(diǎn)擊這里點(diǎn)擊這里查看更多文章教程this.textBox3.Location = new System.Drawing.Point(32, 232);this.textBox3.Multiline = true;this.textBox3.Name = textBox3;this.textBox3.Re
18、adOnly = true;this.textBox3.ScrollBars = System.Windows.Forms.ScrollBars.Both;this.textBox3.Size = new System.Drawing.Size(504, 120);this.textBox3.TabIndex = 18;this.textBox3.Text = ;/ checkBox1/this.checkBox1.Location = new System.Drawing.Point(64, 192);this.checkBox1.Name = checkBox1;this.checkBox
19、1.TabIndex = 20;this.checkBox1.Text = 修改公司名稱;/ checkBox2/this.checkBox2.Location = new System.Drawing.Point(200, 192);this.checkBox2.Name = checkBox2;this.checkBox2.TabIndex = 21;this.checkBox2.Text = 修改部門名稱;/ checkBox3/this.checkBox3.Location = new System.Drawing.Point(336, 192);this.checkBox3.Name
20、 = checkBox3;this.checkBox3.TabIndex = 22;this.checkBox3.Text = 修改部門領(lǐng)導(dǎo);/ label5/this.label5.AutoSize = true;this.label5.Location = new System.Drawing.Point(40, 160);this.label5.Name = label5;this.label5.Size = new System.Drawing.Size(79, 17);this.label5.TabIndex = 19;this.label5.Text = 新的部門領(lǐng)導(dǎo);/ text
21、Box4/this.textBox4.Location = new System.Drawing.Point(144, 160);this.textBox4.Name = textBox4;this.textBox4.Size = new System.Drawing.Size(392, 21);this.textBox4.TabIndex = 23;this.textBox4.Text = 請(qǐng)輸入新領(lǐng)導(dǎo)的姓名全拼(域帳號(hào));/ comboBox3/boBox3.Location = new System.Drawing.Point(144, 48);boBox3.Name = comboBo
22、x3;boBox3.Size = new System.Drawing.Size(121, 20);boBox3.TabIndex = 25;boBox3.SelectedIndexChanged += newSystem.EventHandler(boBox3_SelectedIndexChanged);/ label6/this.label6.AutoSize = true; this.label6.Location = new本文關(guān)鍵字:本文關(guān)鍵字:boBox5.Location = new System.Drawing.Point(416, 80);boBox5.Name = comb
23、oBox5;boBox5.Size = new System.Drawing.Size(121, 20);boBox5.TabIndex = 31;boBox5.SelectedIndexChanged += newSystem.EventHandler(boBox5_SelectedIndexChanged);/ label8/this.label8.Location = new System.Drawing.Point(280, 84);this.label8.Name = label8;this.label8.Size = new System.Drawing.Size(120, 16)
24、;this.label8.TabIndex = 30;this.label8.Text = 選擇級(jí)五子部門(OU);/ comboBox6/boBox6.Location = new System.Drawing.Point(144, 80);boBox6.Name = comboBox6;boBox6.Size = new System.Drawing.Size(121, 20);boBox6.TabIndex = 29;boBox6.SelectedIndexChanged += newSystem.EventHandler(boBox6_Sele1234512345 ctedIndexC
25、hanged);/ label9/this.label9.AutoSize = true;this.label9.Location = new System.Drawing.Point(4, 83);this.label9.Name = label9;this.label9.Size = new System.Drawing.Size(116,歡迎光臨八一學(xué)習(xí)網(wǎng)八一學(xué)習(xí)網(wǎng),點(diǎn)點(diǎn)擊這里擊這里查看更多文章教程17);this.label9.TabIndex = 28;this.label9.Text = 選擇四級(jí)子部門(OU);/ Form1/this.AutoScaleBaseSize = ne
26、w System.Drawing.Size(6, 14);this.ClientSize = new System.Drawing.Size(584, 429);this.Controls.Add(boBox5);this.Controls.Add(this.label8);this.Controls.Add(boBox6);this.Controls.Add(this.label9);this.Controls.Add(boBox4);this.Controls.Add(this.label7);this.Controls.Add(boBox3);this.Controls.Add(this
27、.label6);this.Controls.Add(this.textBox4);this.Controls.Add(this.checkBox3);this.Controls.Add(this.checkBox2);this.Controls.Add(this.checkBox1);this.Controls.Add(this.label5);this.Controls.Add(this.textBox3);this.Controls.Add(this.textBox2);this.Controls.Add(this.textBox1);this.Controls.Add(this.but
28、ton1);this.Controls.Add(this.label4);this.Controls.Add(this.label1);this.Controls.Add(boBox2);this.Controls.Add(this.label3);this.Controls.Add(boBox1);this.Controls.Add(this.label2);this.Name = Form1;this.Text = 按 OU 成批修改信息;this.Load += new System.EventHandler(this.Form1_Load);this.ResumeLayout(fals
29、e);#endregion/ / 應(yīng)用程序的主入口點(diǎn)。/ static void Main()Application.Run(new Form1();private void comboBox1_SelectedIndexChanged(object sender,System.EventArgs e)/str=listBox1.SelectedItem.ToString();str=comboBox1.SelectedItem.ToString();DirectoryEntry de1=new DirectoryEntry();de1.Path=LDAP:/+str+,DC=test,DC=
30、net;trycomboBox2.Items.Clear();comboBox2.Text=;comboBox2.Refresh();foreach (DirectoryEntry ch1 in de1.Children)/textBox1.Text=textBox1.Text+str+rn;/ch.Properties.ToString();string str1=;str1=ch1.SchemaClassName 歡迎光臨八一學(xué)習(xí)網(wǎng)八一學(xué)習(xí)網(wǎng),收藏本篇文章收藏本篇文章.ToString();if (str1=organizationalUnit)comboBox2.Items.Add(ch
31、1.Name.ToString();de1.Close();/textBox1.Text=textBox1.Text+-next-rn;/ MessageBox.Show(finish!);catch(Exception ex)MessageBox.Show(ex.Message);finallyprivate void Form1_Load(object sender, S本文關(guān)鍵字:本文關(guān)鍵字:string strADRoot=;string strName=;if(comboBox1.Text=|comboBox2.Text=)strErr=請(qǐng)選擇合適的 OU;goto e1;if(ch
32、eckBox1.Checked)if(textBox1.Text=)strErr=請(qǐng)輸入新公司名稱;goto e1;if(checkBox2.Checked)if(textBox2.Text=)strErr=請(qǐng)輸入部門名稱!;goto e1;if(checkBox3.Checked)if(textBox4.Text=請(qǐng)輸入新領(lǐng)導(dǎo)的姓名全拼(域帳號(hào)))strErr=請(qǐng)輸入新領(lǐng)導(dǎo)的姓名全拼(域帳號(hào))!;goto e1;/ string strNewManager=;/搜索/檢查是否有重復(fù)的帳號(hào)DirectoryEntry su=new DirectoryEntry(LDAP:/DC=test,DC
33、=net);DirectorySearcher searcher = new DirectorySearcher();searcher.SearchRoot=su;searcher.PropertiesT1234512345 oLoad.Add(CN);searcher.Filter =(&(objectClass=user)(sAMAccountName=+textBox4.Text.ToString()+);searcher.SearchScope = SearchScope.Subtree;searcher.Sort = new SortOption(sAMAccountName
34、,SortDirection.Ascending);SearchResultCollection results = searcher.FindAll();DialogResult dlResult;string strMess=您確認(rèn)要將該 OU 下的用戶的領(lǐng)導(dǎo)更改為:+results.Properties.ToString();dlResult=MessageBox.Show(this,strMess,請(qǐng)確認(rèn),MessageBoxButtons.YesNo,MessageBoxIcon.Question, MessageBoxDefaultButton.Button1,MessageBox
35、Options.RightAlign);if(dlResult = DialogResult.Yes)strManager= results.Properties.ToString();strManager=strManager.Remove(0,7);elsetextBox4.Text=請(qǐng)重新輸入新領(lǐng)導(dǎo)的姓名全拼(域帳號(hào))!;strErr=請(qǐng)重新輸入新領(lǐng)導(dǎo)的姓名全拼(域帳號(hào))!;goto e1;if(!checkBox3.Checked)&(!checkBox2.Checked)&(!checkBox1.Checked)strErr=請(qǐng)選擇要修改的項(xiàng)目!;goto e1;st
36、rADRoot=LDAP:/+str+,DC=test,DC=net;DirectoryEntry de=new DirectoryEntry();de.Path=strADRoot;textBox3.Text=;tryforeach(DirectoryEntry chm in de.Children)string strType=;strType=chm.SchemaClassName.ToString();if(strType.ToUpper()=USER)strName=chm.Name.ToString();/如果選中了修改領(lǐng)導(dǎo)的話歡迎光臨八一學(xué)習(xí)網(wǎng)八一學(xué)習(xí)網(wǎng),點(diǎn)擊這里點(diǎn)擊這里查看更多
37、文章教程if(checkBox3.Checked)if(chm.Properties.Contains(manager)chm.Properties=strManager;chm.CommitChanges();textBox3.Text=textBox3.Text+chm.Name .ToString()+的領(lǐng)導(dǎo)修改成功!rn;elsechm.Properties.Add(strManager);chm.CommitChanges();textBox3.Text=textBox3.Text+chm.Name .ToString()+的領(lǐng)導(dǎo)添加成功!rn;/修改公司if(checkBox1.C
38、hecked)if(chm.Properties.Contains(company)chm.Properties=textBox1.Text.ToString();chm.CommitChanges();textBox3.Text=textBox3.Text+chm.Name .ToString()+的公司名稱修改成功!rn;elsechm.Properties.Add(textBox1.Text.ToString();chm.CommitChanges();textBox3.Text=textBox3.Text+chm.Name .ToString()+的公司名稱添加成功!rn;/textB
39、ox3.Text=textBox3.Text+ch1.Name .ToString()+rn;/修改部門if(checkBox2.Checked)if(chm.Properties.Contains(department)chm.Properties=textBox2.Text.ToString();chm.CommitChanges();textBox3.Text=textBox3.Text+chm.Name .ToString()+的部門名稱修改成功!rn;elsechm.Properties.Add(textBox2.Text.ToSt本文關(guān)鍵字:本文關(guān)鍵字:str=comboBox2.
40、SelectedItem.ToString()+,+comboBox1.SelectedItem.ToString();DirectoryEntry de1=new DirectoryEntry();de1.Path=LDAP:/+str+,DC=test,DC=net;trycomboBox3.Items.Clear();comboBox3.Text=;comboBox3.Refresh();foreach (DirectoryEntry ch1 in de1.Children)/textBox1.Text=textBox1.Text+str+rn;/ch.Properties.ToStri
41、ng();string str1=;str1=ch1.SchemaClassName.ToString();if (str1=organizationalUnit)comboBox3.Items.Add(ch1.Name.ToString();de1.Close();/textBox1.Text=textBox1.Text+-next-rn;/ MessageBox.Show(finish!);catch(Exception ex)MessageBox.Show(ex.Message);private void comboBox3_SelectedIndexChanged(object sen
42、der,System.EventArgs e)str=comboBox3.SelectedItem.ToString()+,+comboBox2.SelectedItem.ToString()+,+comboBox1.SelectedItem.ToString();DirectoryEntry de1=new DirectoryEntry();de1.Path=LDAP:/+str+,DC=test,DC=net;trycomboBox4.Items.Clear(1234512345 );comboBox4.Text=;comboBox4.Refresh();foreach (DirectoryEntry ch1 in de1.Children)/textBox1.Text=textBox1.Text+str+rn;/ch.Properties.ToString();string str1=;str1=ch1.SchemaClassName.ToString();if (str1=organizationalUnit)comboBox4.Items.Add(ch1.Name.ToString();de1.Close();/textBox1.Text=textBox1.Text+-next-rn;/ MessageBox.Show(finish
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 精裝修住房出租合同
- 恒大地產(chǎn)總承包合同正規(guī)范本
- 建筑施工服務(wù)合同范本
- 信托資金借款合同書格式范本
- 房地產(chǎn)分期付款合同范本
- 《稅務(wù)培訓(xùn)課件》資料
- 財(cái)稅基礎(chǔ)知識(shí)培訓(xùn)
- 無(wú)論何時(shí)紙質(zhì)合同更加安全的總結(jié)陳詞
- 3人合伙合同范本
- 中醫(yī)個(gè)人實(shí)習(xí)總結(jié)
- 新教材人教版高中物理選擇性必修第三冊(cè)全冊(cè)各章節(jié)知識(shí)點(diǎn)考點(diǎn)
- CJT 354-2010 城市軌道交通車輛空調(diào)、采暖及通風(fēng)裝置技術(shù)條件
- 暑假作業(yè) 11 高二英語(yǔ)語(yǔ)法填空20篇(原卷版)-【暑假分層作業(yè)】2024年高二英語(yǔ)暑假培優(yōu)練(人教版2019)
- 2024年江西省南昌市南昌縣中考一模數(shù)學(xué)試題(含解析)
- 繪本的分鏡設(shè)計(jì)-分鏡的編排
- 查干淖爾一號(hào)井環(huán)評(píng)
- 體檢中心分析報(bào)告
- 人教版初中英語(yǔ)七八九全部單詞(打印版)
- 最高人民法院婚姻法司法解釋(二)的理解與適用
- 關(guān)于醫(yī)保應(yīng)急預(yù)案
- 新人教版五年級(jí)上冊(cè)數(shù)學(xué)應(yīng)用題大全doc
評(píng)論
0/150
提交評(píng)論