summaryrefslogtreecommitdiff
path: root/source3/passdb
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2002-06-14 03:44:38 +0000
committerAndrew Bartlett <abartlet@samba.org>2002-06-14 03:44:38 +0000
commit7591cb5ee38ff220aa3363a01f9751ff41732a3d (patch)
treedc9c9e3d1ce639f73a89c256674129a7ee376fa2 /source3/passdb
parenta770dd49a4d7df1d58912250358f523a12342982 (diff)
downloadsamba-7591cb5ee38ff220aa3363a01f9751ff41732a3d.tar.gz
samba-7591cb5ee38ff220aa3363a01f9751ff41732a3d.tar.bz2
samba-7591cb5ee38ff220aa3363a01f9751ff41732a3d.zip
Convenience function to allow a SID to be specified as a string.
(for use in passdb modules like pdb_xml or a new pdb_ldap that stores sids etc.) Andrew Bartlett (This used to be commit c70b2c4fb72f251a14e0fc88b6520d69a0889bc2)
Diffstat (limited to 'source3/passdb')
-rw-r--r--source3/passdb/pdb_get_set.c49
1 files changed, 46 insertions, 3 deletions
diff --git a/source3/passdb/pdb_get_set.c b/source3/passdb/pdb_get_set.c
index 980850b89c..bbb0d87f59 100644
--- a/source3/passdb/pdb_get_set.c
+++ b/source3/passdb/pdb_get_set.c
@@ -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;