Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 261
  • Last Modified:

Date Range in Active Directory

I was trying to find some example to retrieve user based on Date Range.

For Eg: if i give a date like 1/01/2011 to 31/01/2011 in my windows application.

I wanna retrieve the user info , created on these date ranges.

For Eg: User Bob Created on 15/01/2001,then i have to retrieve that user name.

but am not sure what's the "Search Filter" for that.

Any help appreciated
0
Sha1395
Asked:
Sha1395
  • 2
  • 2
2 Solutions
 
ramkihardyCommented:
HI,
    get the dates entered by the user and convert it to datetime....
like this
Get the Date from the two date fields and convert them to DateTime by using Convert.ToDateTime(DateFiledValue) write a query like this
string SQL=Select Username from UserMst where name='Bob' and Created on between 'Converted From Date Field Value ' AND 'Converted To Date Field Value'.....
This query will give the desired result............
If Any Help please Let me know...
Mark it as answer if it is helpful...
With Regards



0
 
Sha1395Author Commented:
Hi Ramki,

Am not querying SQL,i havey to Query Active Directory.
0
 
ramkihardyCommented:
Sorry shah...I didnt noticed it....i have also a another solution...use can query active directy from your sql server...see this example......http://support.microsoft.com/kb/319716.....and also this might be very helpfull.http://www.codeproject.com/KB/system/everythingInAD.aspx...
pls let me know if u want anyother....
0
 
Sha1395Author Commented:
Thanks Ramki,

I checked codeproject,none of them give an example or syntax for "date range" search filter.

I can't use Sql Server,bcoz my requirement is to write a Class Library file (DLL) on C#.

Appreciated for your help
0
 
DhaestCommented:
Perhaps you can retrieve all the users (without the date-range) and check this in an if-statement to see if the user is created within these dates?

if(user.properties["whenCreated"].value > StartDate && user.properties["whenCreated"].value < EndData)
{
user.properties["whenCreated"].value.ToString()
}
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now