r17064: lsa_GetUserName needs to return the name for S-1-5-7 on an anonymous login.
authorVolker Lendecke <vlendec@samba.org>
Sat, 15 Jul 2006 17:55:01 +0000 (17:55 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 16:38:10 +0000 (11:38 -0500)
Found that because I want to play around with setsharesecurity, for this I
need the "whoami" call figuring out the SID of the currently connected user.

Not activating this test yet until the build farm has picked up the new samba4
revision.

Volker
(This used to be commit 5cfe482841b77208b68376f9e2b8a4a62271f7c9)

source3/rpc_server/srv_lsa_nt.c

index 2cc5ef6110492ed592d1c0cf42ae3f89b0c4a4f0..b4b8876db066928575f006c84d9d4f9e70c5ff29 100644 (file)
@@ -1514,14 +1514,26 @@ NTSTATUS _lsa_enum_accounts(pipes_struct *p, LSA_Q_ENUM_ACCOUNTS *q_u, LSA_R_ENU
 
 NTSTATUS _lsa_unk_get_connuser(pipes_struct *p, LSA_Q_UNK_GET_CONNUSER *q_u, LSA_R_UNK_GET_CONNUSER *r_u)
 {
-       fstring username, domname;
+       const char *username, *domname;
        user_struct *vuser = get_valid_user_struct(p->vuid);
   
        if (vuser == NULL)
                return NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
-  
-       fstrcpy(username, vuser->user.smb_name);
-       fstrcpy(domname, vuser->user.domain);
+
+       if (vuser->guest) {
+               /*
+                * I'm 99% sure this is not the right place to do this,
+                * global_sid_Anonymous should probably be put into the token
+                * instead of the guest id -- vl
+                */
+               if (!lookup_sid(p->mem_ctx, &global_sid_Anonymous,
+                               &domname, &username, NULL)) {
+                       return NT_STATUS_NO_MEMORY;
+               }
+       } else {
+               username = vuser->user.smb_name;
+               domname = vuser->user.domain;
+       }
   
        r_u->ptr_user_name = 1;
        init_unistr2(&r_u->uni2_user_name, username, UNI_STR_TERMINATE);