Filter Inactive DL's from the LDAP search
Posted By: Anuradhachowdary Posted Date: January 29, 2010
Points:2 Category :C#
|
| hi , iam using LDAP to get the DL(distribution lists)names from my domain.but iam getting Inactive DL names also...how to filter inactive DL's from my domain. is there any filter like that. please see the below code what iam using.... please help me in this regard.Thanks in advance.
Dim search As DirectorySearcher Dim entry As DirectoryEntry Dim count As Integer = 0 Dim txtDlName As String Dim lstrreutrn As Boolean = False txtDlName = Request.QueryString("DLnameForLDAP") Dim lstrDLname As String = txtDlName.Trim()
Dim ldstDL As DataSet = New DataSet() Dim ldt As DataTable = ldstDL.Tables.Add() ldt.Columns.Add("DLname", GetType(String)) entry = New DirectoryEntry("LDAP://DC=domain,DC=com") ', Domainwithuser, password); search = New DirectorySearcher(entry) search.Filter = "CN=" & lstrDLname & "*" Dim i As Integer = search.Filter.Length
For Each AdObj As SearchResult In search.FindAll() If (AdObj.GetDirectoryEntry().SchemaEntry.Name = "group") Then Dim dr As DataRow = ldt.NewRow() dr("DLname") = AdObj.GetDirectoryEntry().Name.Substring(3) If dr("DLname").ToString().Length > 1 Then ldt.Rows.Add(dr) End If count += 1 End If Next ldstDL.Tables(0).TableName = "DLDetails" Return ldstDL.GetXml()
|
|
You must Sign In To post reply
|