summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2001-12-03 11:11:14 +0000
committerAndrew Tridgell <tridge@samba.org>2001-12-03 11:11:14 +0000
commit6f907af4e73b53c3ddab934ba954788a2134b913 (patch)
tree03298800cbb068993d1650813e7d54db610780ab /source3/lib
parentc868fe502bb9ea2b5c5452a49f89ec19ab58f2ba (diff)
downloadsamba-6f907af4e73b53c3ddab934ba954788a2134b913.tar.gz
samba-6f907af4e73b53c3ddab934ba954788a2134b913.tar.bz2
samba-6f907af4e73b53c3ddab934ba954788a2134b913.zip
put sid_to_name behind the winbindd backend interface
I spent quite a while trying to work out how to make this call via ldap and failed. I then found that MS servers seem use rpc for sid_to_name, and it works even when in native mode, I ended up just implementing it via rpc (This used to be commit 789833b44e342c0b5de463ed8f9b5f7474a99f27)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/util_sid.c38
1 files changed, 26 insertions, 12 deletions
diff --git a/source3/lib/util_sid.c b/source3/lib/util_sid.c
index 0f1b22ca27..7e9299b053 100644
--- a/source3/lib/util_sid.c
+++ b/source3/lib/util_sid.c
@@ -498,7 +498,7 @@ BOOL sid_linearize(char *outbuf, size_t len, DOM_SID *sid)
{
size_t i;
- if(len < sid_size(sid))
+ if (len < sid_size(sid))
return False;
SCVAL(outbuf,0,sid->sid_rev_num);
@@ -527,10 +527,11 @@ BOOL sid_parse(char *inbuf, size_t len, DOM_SID *sid)
return True;
}
+
/*****************************************************************
- Compare two sids.
+ Compare the domain portion of two sids.
*****************************************************************/
-int sid_compare(const DOM_SID *sid1, const DOM_SID *sid2)
+int sid_compare_domain(const DOM_SID *sid1, const DOM_SID *sid2)
{
int i;
@@ -538,14 +539,6 @@ int sid_compare(const DOM_SID *sid1, const DOM_SID *sid2)
if (!sid1) return -1;
if (!sid2) return 1;
- /* compare most likely different rids, first: i.e start at end */
- for (i = sid1->num_auths-1; i >= 0; --i)
- if (sid1->sub_auths[i] != sid2->sub_auths[i])
- return sid1->sub_auths[i] - sid2->sub_auths[i];
-
- if (sid1->num_auths != sid2->num_auths)
- return sid1->num_auths - sid2->num_auths;
-
if (sid1->sid_rev_num != sid2->sid_rev_num)
return sid1->sid_rev_num - sid2->sid_rev_num;
@@ -556,11 +549,32 @@ int sid_compare(const DOM_SID *sid1, const DOM_SID *sid2)
return 0;
}
-
/*****************************************************************
Compare two sids.
*****************************************************************/
+int sid_compare(const DOM_SID *sid1, const DOM_SID *sid2)
+{
+ int i;
+ if (sid1 == sid2) return 0;
+ if (!sid1) return -1;
+ if (!sid2) return 1;
+
+ /* compare most likely different rids, first: i.e start at end */
+ if (sid1->num_auths != sid2->num_auths)
+ return sid1->num_auths - sid2->num_auths;
+
+ for (i = sid1->num_auths-1; i >= 0; --i)
+ if (sid1->sub_auths[i] != sid2->sub_auths[i])
+ return sid1->sub_auths[i] - sid2->sub_auths[i];
+
+ return sid_compare_domain(sid1, sid2);
+}
+
+
+/*****************************************************************
+ Compare two sids.
+*****************************************************************/
BOOL sid_equal(const DOM_SID *sid1, const DOM_SID *sid2)
{
return sid_compare(sid1, sid2) == 0;