r25401: BUG 4982: Don't delete lanman hashes on invalid logins when
[tprouty/samba.git] / source3 / passdb / pdb_interface.c
index 976dfc1d081b6fb4ff49f34e8aa8f05a8422d180..f038522eed70b36479c19904c49cb1cb2fb609e3 100644 (file)
@@ -8,7 +8,7 @@
 
    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
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
@@ -17,8 +17,7 @@
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "includes.h"
@@ -904,35 +903,28 @@ NTSTATUS pdb_del_groupmem(TALLOC_CTX *mem_ctx, uint32 group_rid,
        return pdb->del_groupmem(pdb, mem_ctx, group_rid, member_rid);
 }
 
-BOOL pdb_find_alias(const char *name, DOM_SID *sid)
-{
-       struct pdb_methods *pdb = pdb_get_methods();
-       return NT_STATUS_IS_OK(pdb->find_alias(pdb, name, sid));
-}
-
 NTSTATUS pdb_create_alias(const char *name, uint32 *rid)
 {
        struct pdb_methods *pdb = pdb_get_methods();
        return pdb->create_alias(pdb, name, rid);
 }
 
-BOOL pdb_delete_alias(const DOM_SID *sid)
+NTSTATUS pdb_delete_alias(const DOM_SID *sid)
 {
        struct pdb_methods *pdb = pdb_get_methods();
-       return NT_STATUS_IS_OK(pdb->delete_alias(pdb, sid));
-                                                           
+       return pdb->delete_alias(pdb, sid);
 }
 
-BOOL pdb_get_aliasinfo(const DOM_SID *sid, struct acct_info *info)
+NTSTATUS pdb_get_aliasinfo(const DOM_SID *sid, struct acct_info *info)
 {
        struct pdb_methods *pdb = pdb_get_methods();
-       return NT_STATUS_IS_OK(pdb->get_aliasinfo(pdb, sid, info));
+       return pdb->get_aliasinfo(pdb, sid, info);
 }
 
-BOOL pdb_set_aliasinfo(const DOM_SID *sid, struct acct_info *info)
+NTSTATUS pdb_set_aliasinfo(const DOM_SID *sid, struct acct_info *info)
 {
        struct pdb_methods *pdb = pdb_get_methods();
-       return NT_STATUS_IS_OK(pdb->set_aliasinfo(pdb, sid, info));
+       return pdb->set_aliasinfo(pdb, sid, info);
 }
 
 NTSTATUS pdb_add_aliasmem(const DOM_SID *alias, const DOM_SID *member)
@@ -1176,7 +1168,7 @@ static NTSTATUS pdb_default_rename_sam_account (struct pdb_methods *methods, str
 
 static NTSTATUS pdb_default_update_login_attempts (struct pdb_methods *methods, struct samu *newpwd, BOOL success)
 {
-       return NT_STATUS_OK;
+       return NT_STATUS_NOT_IMPLEMENTED;
 }
 
 static NTSTATUS pdb_default_setsampwent(struct pdb_methods *methods, BOOL update, uint32 acb_mask)
@@ -1305,7 +1297,28 @@ static BOOL pdb_default_sid_to_id(struct pdb_methods *methods,
                goto done;
        }
 
-       if (sid_peek_check_rid(&global_sid_Builtin, sid, &rid)) {
+       /* check for "Unix User" */
+
+       if ( sid_peek_check_rid(&global_sid_Unix_Users, sid, &rid) ) {
+               id->uid = rid;
+               *type = SID_NAME_USER;
+               ret = True;             
+               goto done;              
+       }
+       
+       /* check for "Unix Group" */
+
+       if ( sid_peek_check_rid(&global_sid_Unix_Groups, sid, &rid) ) {
+               id->gid = rid;
+               *type = SID_NAME_ALIAS;
+               ret = True;             
+               goto done;              
+       }
+       
+       /* BUILTIN */
+
+       if (sid_check_is_in_builtin(sid) ||
+           sid_check_is_in_wellknown_domain(sid)) {
                /* Here we only have aliases */
                GROUP_MAP map;
                if (!NT_STATUS_IS_OK(methods->getgrsid(methods, &map, *sid))) {
@@ -1327,7 +1340,7 @@ static BOOL pdb_default_sid_to_id(struct pdb_methods *methods,
                goto done;
        }
 
-       DEBUG(5, ("Sid %s is neither ours nor builtin, don't know it\n",
+       DEBUG(5, ("Sid %s is neither ours, a Unix SID, nor builtin\n",
                  sid_string_static(sid)));
 
  done:
@@ -2139,7 +2152,6 @@ NTSTATUS make_pdb_method( struct pdb_methods **methods )
        (*methods)->set_unix_primary_group = pdb_default_set_unix_primary_group;
        (*methods)->add_groupmem = pdb_default_add_groupmem;
        (*methods)->del_groupmem = pdb_default_del_groupmem;
-       (*methods)->find_alias = pdb_default_find_alias;
        (*methods)->create_alias = pdb_default_create_alias;
        (*methods)->delete_alias = pdb_default_delete_alias;
        (*methods)->get_aliasinfo = pdb_default_get_aliasinfo;