我需要修改已添加到模式的自定義屬性,但是以所有用戶爲基礎。該屬性是一個MD5哈希,我已經存儲爲一個公共變量。我正在嘗試獲取指定OU中的所有用戶的列表,以便在列表框中列出,以便您可以選擇所有用戶或單個用戶來應用這些值。在Active Directory中查詢OU中的所有用戶並將用戶名輸出到列表框
這裏是我的Form1.cs的
當前代碼using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Security.Cryptography;
using System.DirectoryServices;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
String Password;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
Password = textBox1.Text;
}
private void button1_Click(object sender, EventArgs e)
{
System.Security.Cryptography.MD5CryptoServiceProvider x = new System.Security.Cryptography.MD5CryptoServiceProvider();
byte[] bs = System.Text.Encoding.UTF8.GetBytes(Password);
bs = x.ComputeHash(bs);
System.Text.StringBuilder s = new System.Text.StringBuilder();
foreach (byte b in bs)
{
s.Append(b.ToString("x2").ToLower());
}
Password = s.ToString();
textBox2.Text = Password;
}
private void button2_Click(object sender, EventArgs e)
{
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void button3_Click(object sender, EventArgs e)
{
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
}
什麼問題? –
我該如何去獲取所有的用戶,而不僅僅是特定的用戶,而是將所有的信息都放入一個數組或者可以在列表框中顯示的東西 –