以下は私のコードです。姓または名が同じグリッド内のすべてのユーザーを取得したいと考えています。しかし、ここではソートされたグリッド内の名前自体を取得しています。
ユーザー名を入力する選択肢をユーザーに与えています。彼が名前を入力すると、Active Directory で検索して、ユーザーが入力したテキストで始まるすべてのユーザーを返すことができるはずです。
すべての可能性を表示できる必要があります。たとえば、ユーザーが入力した場合、表示adam
するかどうかを選択する選択肢を与える必要がありadam josef
ますadam john
。
どんな提案も役に立ちます。
ここにコードがあります
DirectoryEntry de = new DirectoryEntry("ADConnection");
DirectorySearcher deSearch = new DirectorySearcher(de);
//set the search filter
deSearch.SearchRoot = de;
String UserName = txt_To.Text;
deSearch.Filter = "(&(objectCategory=user)(GivenName=*" + UserName + "*))";
string[] arrPropertiesToLoad = { "sn" };
deSearch.PropertiesToLoad.AddRange(arrPropertiesToLoad);
SearchResultCollection sResultColl = deSearch.FindAll();//Getting undefined error
Gridview1.DataSource = sResultColl ;
Gridview1.DataBind();
ここにスタックトレースがあります
[COMException (0x80004005): 不明なエラー]
System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail) +439513
System.DirectoryServices.DirectoryEntry.Bind() +36
System.DirectoryServices.DirectoryEntry.get_AdsObject() +31
System.DirectoryServices.DirectorySearcher. FindAll(Boolean findMoreThanOne) +78
System.DirectoryServices.DirectorySearcher.FindAll() +9
C:\Users\273714\documents\visual studio 2010\Projects\Certificate\Certificate\ の Certificate.WebForm4.btngo0_Click(オブジェクト送信者、EventArgs e) WebForm4.aspx.cs:202
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +112
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page .RaisePostBackEvent(NameValueCollection postData) +36 System.Web.UI.Page.ProcessRequestMain(ブール値 includeStagesBeforeAsyncPoint、ブール値 includeStagesAfterAsyncPoint) +5563