summaryrefslogtreecommitdiff
path: root/source3/lib/sids.c
diff options
context:
space:
mode:
authorLuke Leighton <lkcl@samba.org>1998-12-01 19:10:44 +0000
committerLuke Leighton <lkcl@samba.org>1998-12-01 19:10:44 +0000
commit04e382fb166a64de193dc3c7b21187d8382eaeea (patch)
treef8935ebbbabfe2b2d2368aca14113931c323cd94 /source3/lib/sids.c
parente2d51234002609f00bfa92b8031ac15616d6fe26 (diff)
downloadsamba-04e382fb166a64de193dc3c7b21187d8382eaeea.tar.gz
samba-04e382fb166a64de193dc3c7b21187d8382eaeea.tar.bz2
samba-04e382fb166a64de193dc3c7b21187d8382eaeea.zip
rpc_samr.h parse_samr.c srv_samr.c :
samr_query_aliasmembers (cool!) util_pwdb.c sids.c nmbd.c server.c smbpasswd.c swat.c : pwdb_initialise(BOOL is_server) now creates / reads DOMAIN_NAME.SID if is_server is True, and does LsaQueryInfoPolicy(levels 3 and 5) to obtain member and pdc sids. (This used to be commit 3e1eb4f26b67e484b05e1dde94fd4e4dae982631)
Diffstat (limited to 'source3/lib/sids.c')
-rw-r--r--source3/lib/sids.c80
1 files changed, 50 insertions, 30 deletions
diff --git a/source3/lib/sids.c b/source3/lib/sids.c
index cd64f1b097..4a2a5d4805 100644
--- a/source3/lib/sids.c
+++ b/source3/lib/sids.c
@@ -149,19 +149,10 @@ void get_sam_domain_name(void)
}
/****************************************************************************
- obtain the sid from the PDC. do some verification along the way...
+ obtain the sid from the PDC.
****************************************************************************/
BOOL get_member_domain_sid(void)
{
- POLICY_HND pol;
- fstring srv_name;
- struct cli_state cli;
- BOOL res = True;
- DOM_SID sid3;
- DOM_SID sid5;
- fstring dom3;
- fstring dom5;
-
switch (lp_server_role())
{
case ROLE_DOMAIN_NONE:
@@ -181,6 +172,27 @@ BOOL get_member_domain_sid(void)
}
}
+ return get_domain_sids(NULL, &global_member_sid);
+}
+
+/****************************************************************************
+ obtain the sid from the PDC. do some verification along the way...
+****************************************************************************/
+BOOL get_domain_sids(DOM_SID *sid3, DOM_SID *sid5)
+{
+ POLICY_HND pol;
+ fstring srv_name;
+ struct cli_state cli;
+ BOOL res = True;
+ fstring dom3;
+ fstring dom5;
+
+ if (sid3 == NULL && sid5 == NULL)
+ {
+ /* don't waste my time... */
+ return False;
+ }
+
if (!cli_connect_serverlist(&cli, lp_passwordserver()))
{
DEBUG(0,("get_member_domain_sid: unable to initialise client connection.\n"));
@@ -194,8 +206,14 @@ BOOL get_member_domain_sid(void)
fstrcpy(dom3, "");
fstrcpy(dom5, "");
- ZERO_STRUCT(sid3);
- ZERO_STRUCT(sid5);
+ if (sid3 != NULL)
+ {
+ ZERO_STRUCTP(sid3);
+ }
+ if (sid5 != NULL)
+ {
+ ZERO_STRUCTP(sid5);
+ }
fstrcpy(srv_name, "\\\\");
fstrcat(srv_name, global_myname);
@@ -207,11 +225,17 @@ BOOL get_member_domain_sid(void)
/* lookup domain controller; receive a policy handle */
res = res ? do_lsa_open_policy(&cli, srv_name, &pol, False) : False;
- /* send client info query, level 3. receive domain name and sid */
- res = res ? do_lsa_query_info_pol(&cli, &pol, 3, dom3, &sid3) : False;
+ if (sid3 != NULL)
+ {
+ /* send client info query, level 3. receive domain name and sid */
+ res = res ? do_lsa_query_info_pol(&cli, &pol, 3, dom3, sid3) : False;
+ }
- /* send client info query, level 5. receive domain name and sid */
- res = res ? do_lsa_query_info_pol(&cli, &pol, 5, dom5, &sid5) : False;
+ if (sid5 != NULL)
+ {
+ /* send client info query, level 5. receive domain name and sid */
+ res = res ? do_lsa_query_info_pol(&cli, &pol, 5, dom5, sid5) : False;
+ }
/* close policy handle */
res = res ? do_lsa_close(&cli, &pol) : False;
@@ -225,10 +249,16 @@ BOOL get_member_domain_sid(void)
{
pstring sid;
DEBUG(2,("LSA Query Info Policy\n"));
- sid_to_string(sid, &sid3);
- DEBUG(2,("Domain Member - Domain: %s SID: %s\n", dom3, sid));
- sid_to_string(sid, &sid5);
- DEBUG(2,("Domain Controller - Domain: %s SID: %s\n", dom5, sid));
+ if (sid3 != NULL)
+ {
+ sid_to_string(sid, sid3);
+ DEBUG(2,("Domain Member - Domain: %s SID: %s\n", dom3, sid));
+ }
+ if (sid5 != NULL)
+ {
+ sid_to_string(sid, sid5);
+ DEBUG(2,("Domain Controller - Domain: %s SID: %s\n", dom5, sid));
+ }
if (!strequal(dom3, global_myworkgroup) ||
!strequal(dom5, global_myworkgroup))
@@ -243,16 +273,6 @@ BOOL get_member_domain_sid(void)
DEBUG(1,("lsa query info failed\n"));
}
- if (!res)
- {
- DEBUG(0,("get_member_domain_sid: unable to obtain Domain member SID\n"));
- }
- else
- {
- /* this is a _lot_ of trouble to go to for just this info: */
- global_member_sid = sid5;
- }
-
return res;
}