.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> C# >> Post New QuestionBookmark and Share Subscribe to Forum

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()

Responses
Author: Sagar Pardeshi             
Posted Date: January 29, 2010     Points: 5   

HI i will suggest simple u can get all information of ldap using sql quary.or send me ur id i will send complet ldap code project

Author: Sagar Pardeshi             
Posted Date: January 29, 2010     Points: 5   

reply i will give u ldap query or code project

Author: Sagar Pardeshi             
Posted Date: January 29, 2010     Points: 5   

sp_addlinkedserver 'ADSI', 'Active Directory Service Interfaces', 'ADSDSOObject', 'adsdatasource'



--only get all users

SELECT * FROM OpenQuery(ADSI, 'SELECT GivenName, sn,sAMAccountName, cn, mail, displayName, department, telephoneNumber,mobile,streetAddress, st, distinguishedName, physicalDeliveryOfficeName FROM ''LDAP://DC=emanon,DC=com'' WHERE objectClass=''User''')

--only get all grops


SELECT * FROM OpenQuery(ADSI, 'SELECT groupMembershipSAM,title,PwdLastSet, GivenName, sn,sAMAccountName, cn, mail, displayName, department, telephoneNumber,streetAddress, st, distinguishedName, physicalDeliveryOfficeName FROM ''LDAP://DC=domain,DC=com'' WHERE objectClass=''group''')

--get all users ans grups
SELECT * FROM OpenQuery(ADSI, 'SELECT title,PwdLastSet, GivenName, sn,sAMAccountName, cn, mail, displayName, department, telephoneNumber,streetAddress, st, distinguishedName, physicalDeliveryOfficeName FROM ''LDAP://DC=domain,DC=com'' WHERE objectClass=''User'' AND objectClass=''group''')


use this quary in .net code all inforation store in datatable..or send ur mail id i send u code

Author: Anuradhachowdary             
Posted Date: February 02, 2010     Points: 5   

hi sagar pardeshi ,
thanks for the reply...but i need to filter it from C# code....
not from the sql query....
do we have any filter for finding inactive DL's??

Thanks,
Anuradha

Author: Sagar Pardeshi             
Posted Date: February 02, 2010     Points: 5   

yaa.i send u code project check ur scrap book in your dotnetspark.com profile and reply me or send ur mail id

Author: Anuradhachowdary             
Posted Date: February 03, 2010     Points: 5   

hi,
is it possible to change the existing code what i have posted??to eliminate inactive DL's?

Author: Sagar Pardeshi             
Posted Date: February 03, 2010     Points: 5   

HI friend ,

send me mail id i send u code project.ur problem will solve.

Author: Anuradhachowdary             
Posted Date: February 03, 2010     Points: 5   

hi,
is it possible to change the existing code what i have posted??to eliminate inactive DL's?

Author: Sagar Pardeshi             
Posted Date: February 03, 2010     Points: 5   

HI friend ,

send me mail id i send u code project.ur problem will solve.

Author: Anuradhachowdary             
Posted Date: February 03, 2010     Points: 5   

pls send it to anu_mamil@yahoo.com

Author: Sagar Pardeshi             
Posted Date: February 03, 2010     Points: 5   

ok wait

Author: Sagar Pardeshi             
Posted Date: February 03, 2010     Points: 5   

check ur in box

Author: Anuradhachowdary             
Posted Date: February 03, 2010     Points: 5   

thanks for the code...i saw the code...but how do u find wether a perticular DL is active or not...
i didt find any code related to that..
pls explin...

Thanks
anuradha

Author: Sagar Pardeshi             
Posted Date: February 03, 2010     Points: 5   

send gmail id

Author: Anuradhachowdary             
Posted Date: February 03, 2010     Points: 5   

iam unable to chat from office

Author: Sagar Pardeshi             
Posted Date: February 03, 2010     Points: 5   

ohh.ask question?

Author: Sagar Pardeshi             
Posted Date: February 03, 2010     Points: 5   

u can debug and find u got .i have send correct code .u can attach breakpoints and point u got it.

Author: Anuradhachowdary             
Posted Date: February 03, 2010     Points: 5   

i didt get u....if u tell me the case ..where u have written in ur code..or any thing else need to be added for my code ...thats enough...could u expian that...
because it is urgent for me....

Author: Sagar Pardeshi             
Posted Date: February 03, 2010     Points: 5   

u can debug and find u got .i have send correct code .u can attach breakpoints and point u got it.

Author: Sagar Pardeshi             
Posted Date: February 03, 2010     Points: 5   

tell me ur requrient or send me ur code bye mail

Author: Sagar Pardeshi             
Posted Date: February 03, 2010     Points: 5   

send me ur code project i try on my side all type one notepad file what u expected result

Author: Anuradhachowdary             
Posted Date: February 03, 2010     Points: 5   

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()



this is the code iam using ...iam using this data set(ldstDL).it is properly connecting to My domain's AD and filtering Distribution lists(DL's).along with active DL names it is taking Inactive DL's also.

how can i eliminate that inactive things.

Author: Sagar Pardeshi             
Posted Date: February 03, 2010     Points: 5   

If (AdObj.GetDirectoryEntry().SchemaEntry.Name = "User") change then use

Author: Anuradhachowdary             
Posted Date: February 03, 2010     Points: 5   

If (AdObj.GetDirectoryEntry().SchemaEntry.Name = "User") then it will filter only user names not DL names..that is why i have specified (AdObj.GetDirectoryEntry().SchemaEntry.Name = "Group").
then it will take only DL names not the user names...
i hope iam right!!!



Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend