我的页面中有一个表单,用户通知其他用户的电子邮件或用户名。在我的提交事件中,我需要检查此信息是否存在于 Active Directory 中。我怎么做这个检查?我很清楚?
我的页面
<asp:Label ID="lblUserAdd" runat="server" Font-Bold="true" Text="Add User - (Email or User Name)"></asp:Label>
<br />
<asp:TextBox ID="txtUserAdd" runat="server" Height="17px" Width="150px"></asp:TextBox>
<asp:Label ID="lblError" runat="server" class="control-label" for="inputError" Visible="false">Input with error</asp:Label>
<asp:Label ID="lblsuccess" runat="server" class="control-label" for="inputSuccess"
Visible="false">Input with success</asp:Label>
<asp:Button ID="btnAddUser" class="btn" runat="server" Font-Bold="true" Text="Add User"
OnClick="btnSendUser_OnClick" />
<br />
<table id="tblUsers" class="table table-bordered">
<asp:Label ID="lblUser" runat="server" Visible="false"></asp:Label>
</table>
我的.cs
protected void btnSendUser_OnClick(object sender, EventArgs e)
{
PrincipalContext ADDomain = new PrincipalContext(ContextType.Domain, "x.com", "amsndruser", "x");
lblUser.Visible = true;
lblUser.Text = txtUserAdd.Text;
if (txtUserAdd.Text != "EMAIL AD" || txtUserAdd.Text != "USER NAME AD" || txtUserAdd.Text != "USER AD")
{
lblError.Visible = true;
}
else
{
lblsuccess.Visible = true;
}
}