int samdb_result_effective_badPwdCount(struct ldb_context *sam_ldb,
				       TALLOC_CTX *mem_ctx,
				       struct ldb_dn *domain_dn,
				       const struct ldb_message *user_msg)
{
	struct timeval tv_now = timeval_current();
	NTTIME now = timeval_to_nttime(&tv_now);
	int64_t lockOutObservationWindow;
	struct ldb_result *res = NULL;
	const char *attrs[] = { "msDS-LockoutObservationWindow",
				NULL };

	res = lookup_user_pso(sam_ldb, mem_ctx, user_msg, attrs);

	if (res != NULL) {
		lockOutObservationWindow =
			ldb_msg_find_attr_as_int64(res->msgs[0],
						   "msDS-LockoutObservationWindow",
						    DEFAULT_OBSERVATION_WINDOW);
		talloc_free(res);
	} else {

		/* no PSO was found, lookup the default domain setting */
		lockOutObservationWindow =
			 samdb_search_int64(sam_ldb, mem_ctx, 0, domain_dn,
					    "lockOutObservationWindow", NULL);
	}

	return dsdb_effective_badPwdCount(user_msg, lockOutObservationWindow, now);
}
int samdb_result_effective_badPwdCount(struct ldb_context *sam_ldb,
				       TALLOC_CTX *mem_ctx,
				       struct ldb_dn *domain_dn,
				       const struct ldb_message *user_msg)
{
	struct timeval tv_now = timeval_current();
	NTTIME now = timeval_to_nttime(&tv_now);
	int64_t lockOutObservationWindow;
	struct ldb_result *res = NULL;
	const char *attrs[] = { "msDS-LockoutObservationWindow",
				NULL };

	res = lookup_user_pso(sam_ldb, mem_ctx, user_msg, attrs);

	if (res != NULL) {
		lockOutObservationWindow =
			ldb_msg_find_attr_as_int64(res->msgs[0],
						   "msDS-LockoutObservationWindow",
						    DEFAULT_OBSERVATION_WINDOW);
		talloc_free(res);
	} else {

		 
		lockOutObservationWindow =
			 samdb_search_int64(sam_ldb, mem_ctx, 0, domain_dn,
					    "lockOutObservationWindow", NULL);
	}

	return dsdb_effective_badPwdCount(user_msg, lockOutObservationWindow, now);
}