samdb/cracknames: do not show recycled when a guid is desired
authorBob Campbell <bobcampbell@catalyst.net.nz>
Tue, 4 Jul 2017 23:15:04 +0000 (11:15 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Mon, 24 Jul 2017 05:14:10 +0000 (07:14 +0200)
Previously, when a GUID was desired to
cracknames, it would include recycled objects as well. This would
sometimes result in two objects being returned from a query which is
supposed to return a unique GUID. For example, if a deleted user had
the same sAMAccountName as a non-deleted user and cracknames was used to
find the GUID of this account, it would return two GUIDs, and so would
fail with DRSUAPI_DS_NAME_STATUS_NOT_UNIQUE.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=12842

Signed-off-by: Bob Campbell <bobcampbell@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
source4/dsdb/samdb/cracknames.c

index 14d6a53ac164f6585fa7f15bdf621fb22fc80811..bb25b00046e7feeb6df424cf866ca205fc47c213 100644 (file)
@@ -7,6 +7,7 @@
    Copyright (C) Stefan Metzmacher 2004
    Copyright (C) Andrew Bartlett <abartlet@samba.org> 2004-2005
    Copyright (C) Matthieu Patou <mat@matws.net> 2012
+   Copyright (C) Catalyst .Net Ltd 2017
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -980,7 +981,7 @@ static WERROR DsCrackNameOneFilter(struct ldb_context *sam_ctx, TALLOC_CTX *mem_
                } else {
                        real_search_dn = ldb_get_default_basedn(sam_ctx);
                }
-               if (format_desired == DRSUAPI_DS_NAME_FORMAT_GUID){
+               if (format_offered == DRSUAPI_DS_NAME_FORMAT_GUID){
                         dsdb_flags |= DSDB_SEARCH_SHOW_RECYCLED;
                }
                /* search with the 'phantom root' flag */