Convenience function to allow a SID to be specified as a string.
authorAndrew Bartlett <abartlet@samba.org>
Fri, 14 Jun 2002 03:44:38 +0000 (03:44 +0000)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 14 Jun 2002 03:44:38 +0000 (03:44 +0000)
(for use in passdb modules like pdb_xml or a new pdb_ldap that stores sids etc.)

Andrew Bartlett

source/passdb/pdb_get_set.c

index 980850b89c9cc09abfa2bc6e3af3cdee949fe927..bbb0d87f59f23b299963df169fb5d041470c3da3 100644 (file)
@@ -180,7 +180,7 @@ uint32 pdb_get_user_rid (const SAM_ACCOUNT *sampass)
                if (sid_peek_check_rid(get_global_sam_sid(), pdb_get_user_sid(sampass),&u_rid))
                        return u_rid;
        
-       return (-1);
+       return (0);
 }
 
 uint32 pdb_get_group_rid (const SAM_ACCOUNT *sampass)
@@ -190,7 +190,7 @@ uint32 pdb_get_group_rid (const SAM_ACCOUNT *sampass)
        if (sampass)
                if (sid_peek_check_rid(get_global_sam_sid(), pdb_get_group_sid(sampass),&g_rid))
                        return g_rid;
-       return (-1);
+       return (0);
 }
 
 /**
@@ -521,7 +521,29 @@ BOOL pdb_set_user_sid (SAM_ACCOUNT *sampass, DOM_SID *u_sid)
        return True;
 }
 
-BOOL pdb_set_group_sid(SAM_ACCOUNT *sampass, DOM_SID *g_sid)
+BOOL pdb_set_user_sid_from_string (SAM_ACCOUNT *sampass, fstring u_sid)
+{
+       DOM_SID new_sid;
+       if (!sampass || !u_sid)
+               return False;
+
+       DEBUG(10, ("pdb_set_user_sid_from_string: setting user sid %s\n",
+                  u_sid));
+
+       if (!string_to_sid(&new_sid, u_sid)) { 
+               DEBUG(1, ("pdb_set_user_sid_from_string: %s isn't a valid SID!\n", u_sid));
+               return False;
+       }
+        
+       if (!pdb_set_user_sid(sampass, &new_sid)) {
+               DEBUG(1, ("pdb_set_user_sid_from_string: could not set sid %s on SAM_ACCOUNT!\n", u_sid));
+               return False;
+       }
+
+       return True;
+}
+
+BOOL pdb_set_group_sid (SAM_ACCOUNT *sampass, DOM_SID *g_sid)
 {
        if (!sampass || !g_sid)
                return False;
@@ -534,6 +556,27 @@ BOOL pdb_set_group_sid(SAM_ACCOUNT *sampass, DOM_SID *g_sid)
        return True;
 }
 
+BOOL pdb_set_group_sid_from_string (SAM_ACCOUNT *sampass, fstring g_sid)
+{
+       DOM_SID new_sid;
+       if (!sampass || !g_sid)
+               return False;
+
+       DEBUG(10, ("pdb_set_group_sid_from_string: setting group sid %s\n",
+                  g_sid));
+
+       if (!string_to_sid(&new_sid, g_sid)) { 
+               DEBUG(1, ("pdb_set_group_sid_from_string: %s isn't a valid SID!\n", g_sid));
+               return False;
+       }
+        
+       if (!pdb_set_group_sid(sampass, &new_sid)) {
+               DEBUG(1, ("pdb_set_group_sid_from_string: could not set sid %s on SAM_ACCOUNT!\n", g_sid));
+               return False;
+       }
+       return True;
+}
+
 BOOL pdb_set_user_sid_from_rid (SAM_ACCOUNT *sampass, uint32 rid)
 {
        DOM_SID u_sid;