From a1def4de32ac4de113ea9a8c9b99e6f93ffde950 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 13 Jul 2007 23:36:12 +0000 Subject: r23873: Make use of ads_find_samaccount(). Guenther (This used to be commit 94d11806fd5384cbdd6c12b230985991b9e6473d) --- source3/libgpo/gpo_util.c | 39 +++------------------------------------ 1 file changed, 3 insertions(+), 36 deletions(-) (limited to 'source3/libgpo') diff --git a/source3/libgpo/gpo_util.c b/source3/libgpo/gpo_util.c index 338fa9cda3..368d1206e9 100644 --- a/source3/libgpo/gpo_util.c +++ b/source3/libgpo/gpo_util.c @@ -506,56 +506,23 @@ ADS_STATUS gpo_password_policy(ADS_STRUCT *ads, { ADS_STATUS status; struct GROUP_POLICY_OBJECT *gpo_list; - const char *attrs[] = {"distinguishedName", "userAccountControl", NULL}; - char *filter, *dn; - LDAPMessage *res = NULL; - uint32 uac; - - filter = talloc_asprintf(mem_ctx, "(&(objectclass=user)(sAMAccountName=%s))", hostname); - if (filter == NULL) { - return ADS_ERROR(LDAP_NO_MEMORY); - } + const char *dn = NULL; + uint32 uac = 0; - status = ads_do_search_all(ads, ads->config.bind_path, - LDAP_SCOPE_SUBTREE, - filter, attrs, &res); - + status = ads_find_samaccount(ads, mem_ctx, hostname, &uac, &dn); if (!ADS_ERR_OK(status)) { return status; } - if (ads_count_replies(ads, res) != 1) { - ads_msgfree(ads, res); - return ADS_ERROR(LDAP_NO_SUCH_OBJECT); - } - - dn = ads_get_dn(ads, res); - if (dn == NULL) { - ads_msgfree(ads, res); - return ADS_ERROR(LDAP_NO_MEMORY); - } - - if (!ads_pull_uint32(ads, res, "userAccountControl", &uac)) { - ads_msgfree(ads, res); - ads_memfree(ads, dn); - return ADS_ERROR(LDAP_NO_MEMORY); - } - - ads_msgfree(ads, res); - if (!(uac & UF_WORKSTATION_TRUST_ACCOUNT)) { - ads_memfree(ads, dn); return ADS_ERROR(LDAP_NO_SUCH_OBJECT); } status = ads_get_gpo_list(ads, mem_ctx, dn, GPO_LIST_FLAG_MACHINE, &gpo_list); if (!ADS_ERR_OK(status)) { - ads_memfree(ads, dn); return status; } - ads_memfree(ads, dn); - status = gpo_process_gpo_list(ads, mem_ctx, gpo_list, cse_gpo_name_to_guid_string("Security"), GPO_LIST_FLAG_MACHINE); -- cgit