In my code I have an AJAX AutoComplete, looks like this:
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><ajaxToolkit:AutoCompleteExtender ID="TextBox1_AutoCompleteExtender" runat="server" DelimiterCharacters="" Enabled="True" ServicePath="AutoComplete.asmx" ServiceMethod="GetCompletionList" TargetControlID="TextBox1" CompletionSetCount="10" MinimumPrefixLength="2"></ajaxToolkit:AutoCompleteExtender>
Its fairly straight forward and I have done this kind of thing connecting the Web Service from SQL, however this time within the Web Service I wont to connect to a array from strings. The strings will be the network ID's. The web service looks like:
Imports System.DirectoryServices Imports System.DirectoryServices.AccountManagement Imports System.Web.Services Imports System.Web.Services.Protocols Imports System.ComponentModel ' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. Public Class WebService2 Inherits System.Web.Services.WebService <WebMethod()> _ Public Function GetCompletionList(ByVal prefixText As String, ByVal count As Integer) As List(Of String) Dim ctx As New PrincipalContext(ContextType.Domain) Dim group As GroupPrincipal = GroupPrincipal.FindByIdentity(ctx, "####") ' Create a list of strings. Dim list As New List(Of String) ' if found.... If group IsNot Nothing Then ' iterate over members For Each p As Principal In group.GetMembers() list.Add(p.SamAccountName) Next End If list.Sort() Return list End Function
I could chuck the lot into a database beforehand but wouldn't mind trying to solve the problem in the first instance. Anyone got any suggestions?...
:)