summaryrefslogtreecommitdiff
path: root/source3/libgpo
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2007-07-13 23:36:12 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:28:36 -0500
commita1def4de32ac4de113ea9a8c9b99e6f93ffde950 (patch)
tree39e2412e8779c34ed2864f9dcb0b86118217fbf1 /source3/libgpo
parente997cf9fe2a1ed8546d841acd6f4b3a9ab3676d4 (diff)
downloadsamba-a1def4de32ac4de113ea9a8c9b99e6f93ffde950.tar.gz
samba-a1def4de32ac4de113ea9a8c9b99e6f93ffde950.tar.bz2
samba-a1def4de32ac4de113ea9a8c9b99e6f93ffde950.zip
r23873: Make use of ads_find_samaccount().
Guenther (This used to be commit 94d11806fd5384cbdd6c12b230985991b9e6473d)
Diffstat (limited to 'source3/libgpo')
-rw-r--r--source3/libgpo/gpo_util.c39
1 files changed, 3 insertions, 36 deletions
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);