svn commit: samba r23873 - in branches: SAMBA_3_2/source/libgpo
SAMBA_3_2_0/source/libgpo
gd at samba.org
gd at samba.org
Fri Jul 13 23:36:13 GMT 2007
Author: gd
Date: 2007-07-13 23:36:12 +0000 (Fri, 13 Jul 2007)
New Revision: 23873
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=23873
Log:
Make use of ads_find_samaccount().
Guenther
Modified:
branches/SAMBA_3_2/source/libgpo/gpo_util.c
branches/SAMBA_3_2_0/source/libgpo/gpo_util.c
Changeset:
Modified: branches/SAMBA_3_2/source/libgpo/gpo_util.c
===================================================================
--- branches/SAMBA_3_2/source/libgpo/gpo_util.c 2007-07-13 23:34:42 UTC (rev 23872)
+++ branches/SAMBA_3_2/source/libgpo/gpo_util.c 2007-07-13 23:36:12 UTC (rev 23873)
@@ -506,56 +506,23 @@
{
ADS_STATUS status;
struct GROUP_POLICY_OBJECT *gpo_list;
- const char *attrs[] = {"distinguishedName", "userAccountControl", NULL};
- char *filter, *dn;
- LDAPMessage *res = NULL;
- uint32 uac;
+ const char *dn = NULL;
+ uint32 uac = 0;
- filter = talloc_asprintf(mem_ctx, "(&(objectclass=user)(sAMAccountName=%s))", hostname);
- if (filter == NULL) {
- return ADS_ERROR(LDAP_NO_MEMORY);
- }
-
- 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);
Modified: branches/SAMBA_3_2_0/source/libgpo/gpo_util.c
===================================================================
--- branches/SAMBA_3_2_0/source/libgpo/gpo_util.c 2007-07-13 23:34:42 UTC (rev 23872)
+++ branches/SAMBA_3_2_0/source/libgpo/gpo_util.c 2007-07-13 23:36:12 UTC (rev 23873)
@@ -506,56 +506,23 @@
{
ADS_STATUS status;
struct GROUP_POLICY_OBJECT *gpo_list;
- const char *attrs[] = {"distinguishedName", "userAccountControl", NULL};
- char *filter, *dn;
- LDAPMessage *res = NULL;
- uint32 uac;
+ const char *dn = NULL;
+ uint32 uac = 0;
- filter = talloc_asprintf(mem_ctx, "(&(objectclass=user)(sAMAccountName=%s))", hostname);
- if (filter == NULL) {
- return ADS_ERROR(LDAP_NO_MEMORY);
- }
-
- 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);
More information about the samba-cvs
mailing list