所以这是指我正处于中间的项目。
到目前为止,我已将其硬编码为仅搜索我的名字 - 但我希望能够搜索:
AD 我们的内部网站 并最终我们的授权软件(这将在以后)
我写过了擦除内部页面的部分:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net;
using System.IO;
using System.Text.RegularExpressions;
using System.DirectoryServices;
using System.DirectoryServices.AccountManagement;
namespace Get_Source_Code
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string url = urlTextBox.Text;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader sr = new StreamReader(response.GetResponseStream());
var rawStream = sr.ReadToEnd();
sr.Close();
var myBuilder = new StringBuilder();
rawStream = rawStream.Replace("<br>", " ");
rawStream = rawStream.Replace("<br />", " ");
myBuilder.AppendLine("Employee Name : " + rawStream.Between("<span id=\"Label_DisplayFullName\">", "</span>"));
myBuilder.AppendLine("Title: " + rawStream.Between("<span id=\"Label_Title\">", "</span>"));
myBuilder.AppendLine("Location : " + rawStream.Between("<span id=\"Label_Location\">", "</span>"));
myBuilder.AppendLine("Department : " + rawStream.Between("<span id=\"Label_Department\">", "</span>"));
myBuilder.AppendLine("Group: " + rawStream.Between("<span id=\"Label_Group\">", "</span>"));
myBuilder.AppendLine("Office Phone : " + rawStream.Between("<span id=\"Label_IntPhoneNumber\">", "</span>"));
myBuilder.AppendLine("Mobile Phone : " + rawStream.Between("<span id=\"Label_BusMobile\">", "</span>"));
richTextBox1.Text = myBuilder.ToString();
}
private void urlTextBox_TextChanged(object sender, EventArgs e)
{
}
}
public static class StringHelper
{
public static string Between(this string source, string left, string right)
{
var result = (new Regex(left + "(.*?)" + right)).Match(source).Groups[1].ToString();
if (result == "") result = null;
return result;
}
}
}
我查看了以下答案“Quick way to retrieve user information Active Directory”
看起来正指向我正确的方向。但我仍然对此持绿色态度,并且不确定如何处理这个问题。
特别是因为我试图从一个查询中获取所有内容。