Fix a segfault in pdb_ads_delete_user()
authorVolker Lendecke <vl@samba.org>
Wed, 10 Jun 2009 09:48:31 +0000 (11:48 +0200)
committerVolker Lendecke <vl@samba.org>
Wed, 10 Jun 2009 21:08:09 +0000 (23:08 +0200)
If a user comes from the passdb cache, priv is NULL

source3/passdb/pdb_ads.c

index 8e30dfb5bce51a2bd56a2b5a43d0bc29c152eec3..3081046f2d87ef89d01263cada8b2b160bf11597 100644 (file)
@@ -443,12 +443,20 @@ static NTSTATUS pdb_ads_delete_user(struct pdb_methods *m,
 {
        struct pdb_ads_state *state = talloc_get_type_abort(
                m->private_data, struct pdb_ads_state);
-       struct pdb_ads_samu_private *priv = pdb_ads_get_samu_private(m, sam);
+       NTSTATUS status;
+       char *dn;
        int rc;
 
-       rc = tldap_delete(state->ld, priv->dn, NULL, NULL);
+       status = pdb_ads_sid2dn(state, pdb_get_user_sid(sam), talloc_tos(),
+                               &dn);
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
+       }
+
+       rc = tldap_delete(state->ld, dn, NULL, NULL);
+       TALLOC_FREE(dn);
        if (rc != TLDAP_SUCCESS) {
-               DEBUG(10, ("ldap_delete for %s failed: %s\n", priv->dn,
+               DEBUG(10, ("ldap_delete for %s failed: %s\n", dn,
                           tldap_errstr(debug_ctx(), state->ld, rc)));
                return NT_STATUS_LDAP(rc);
        }