A .NET service that monitors user accounts from multiple LDAP endpoints and manages notifications for account expiration and password changes.
- Monitors multiple LDAP endpoints for user account status
- Tracks account expiration dates and password age
- Sends notifications for:
- Accounts nearing expiration (30 days or less)
- Accounts that have expired
- Passwords that need to be changed (90+ days old)
- Supports multiple LDAP domains
- Maintains history of user status in SQLite database
- Runs daily checks at 8 AM
- .NET 7.0 or later
- For production:
- Windows Server (for LDAP connectivity)
- SMTP server for email notifications
- Access to LDAP/Active Directory servers
- For development:
- Any OS (uses test services)
The application uses the following configuration settings in appsettings.json:
{
"LdapEndpoints": [
"localhost:389",
"test.ldap:389"
],
"ConnectionStrings": {
"DefaultConnection": "Data Source=CwrStatusChecker.db"
},
"EmailSettings": {
"SmtpServer": "smtp.yourserver.com",
"SmtpPort": 587,
"Username": "your-email@domain.com",
"Password": "your-password",
"FromEmail": "notifications@domain.com"
}
}- Clone the repository
- Navigate to the project directory
- Run the application in development mode:
export ASPNETCORE_ENVIRONMENT=Development
dotnet run --project CwrStatusChecker.ServiceIn development mode:
- Uses
TestLdapServiceinstead of real LDAP connections - Uses
TestEmailServicethat logs emails instead of sending them - Uses SQLite database instead of SQL Server
- Runs once and exits (instead of running continuously)
- Build the application:
dotnet publish -c Release-
Configure the application settings in
appsettings.Production.json -
Run as a Windows Service:
sc.exe create "CWR Status Checker" binPath="path\to\CwrStatusChecker.Service.exe"
sc.exe start "CWR Status Checker"- CwrStatusChecker.Service: Main worker service and business logic
Worker.cs: Background service that runs the checksServices/: Service implementations (LDAP, Email)
- CwrStatusChecker.Data: Data access layer
ApplicationDbContext.cs: Entity Framework context
- CwrStatusChecker.Models: Domain models
User.cs: User account model
The application uses a single Users table with the following schema:
- Id (int, primary key)
- Username (string, unique with LdapEndpoint)
- Email (string)
- ManagerEmail (string)
- LastPasswordChange (DateTime?)
- AccountExpirationDate (DateTime?)
- IsDisabled (bool)
- IsArchived (bool)
- LdapEndpoint (string)
- LastChecked (DateTime)
The application includes test services for development:
TestLdapService: Provides test user dataTestEmailService: Logs email notifications instead of sending them
The service sends the following types of notifications:
- Account Expiration Notice: When account expires in 30 days or less
- Account Disabled Notice: When account has expired
- Password Change Required: When password is older than 90 days