lookup_alias_name() %s not %d for sid_str
[samba.git] / source3 / rpc_server / srv_lookup.c
1
2 /* 
3  *  Unix SMB/Netbios implementation.
4  *  Version 1.9.
5  *  RPC Pipe client / server routines
6  *  Copyright (C) Andrew Tridgell              1992-1998
7  *  Copyright (C) Luke Kenneth Casson Leighton 1996-1998,
8  *  Copyright (C) Paul Ashton                  1997-1998.
9  *  
10  *  This program is free software; you can redistribute it and/or modify
11  *  it under the terms of the GNU General Public License as published by
12  *  the Free Software Foundation; either version 2 of the License, or
13  *  (at your option) any later version.
14  *  
15  *  This program is distributed in the hope that it will be useful,
16  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  *  GNU General Public License for more details.
19  *  
20  *  You should have received a copy of the GNU General Public License
21  *  along with this program; if not, write to the Free Software
22  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23  */
24
25 /*
26  *
27  *
28
29  this module provides nt user / nt rid lookup functions.
30  users, local groups, domain groups.
31
32  no unix / samba functions should be called in this module:
33  it should purely provide a gateway to the password database API,
34  the local group database API or the domain group database API,
35  but first checking built-in rids.
36
37  did i say rids?  oops, what about "S-1-1" the "Everyone" group
38  and other such well-known sids...
39
40  speed is not of the essence: no particular optimisation is in place.
41
42  *
43  *
44  */
45
46 #include "includes.h"
47 #include "nterr.h"
48
49 extern int DEBUGLEVEL;
50
51 extern fstring global_sam_name;
52 extern DOM_SID global_sam_sid;
53 extern DOM_SID global_sid_S_1_5_20;
54
55 /*
56  * A list of the rids of well known BUILTIN and Domain users
57  * and groups.
58  */
59
60 rid_name builtin_alias_rids[] =
61 {  
62     { BUILTIN_ALIAS_RID_ADMINS       , "Administrators" },
63     { BUILTIN_ALIAS_RID_USERS        , "Users" },
64     { BUILTIN_ALIAS_RID_GUESTS       , "Guests" },
65     { BUILTIN_ALIAS_RID_POWER_USERS  , "Power Users" },
66    
67     { BUILTIN_ALIAS_RID_ACCOUNT_OPS  , "Account Operators" },
68     { BUILTIN_ALIAS_RID_SYSTEM_OPS   , "System Operators" },
69     { BUILTIN_ALIAS_RID_PRINT_OPS    , "Print Operators" },
70     { BUILTIN_ALIAS_RID_BACKUP_OPS   , "Backup Operators" },
71     { BUILTIN_ALIAS_RID_REPLICATOR   , "Replicator" },
72     { 0                             , NULL }
73 };
74
75 /* array lookup of well-known Domain RID users. */
76 rid_name domain_user_rids[] =
77 {  
78     { DOMAIN_USER_RID_ADMIN         , "Administrator" },
79     { DOMAIN_USER_RID_GUEST         , "Guest" },
80     { 0                             , NULL }
81 };
82
83 /* array lookup of well-known Domain RID groups. */
84 rid_name domain_group_rids[] =
85 {  
86     { DOMAIN_GROUP_RID_ADMINS       , "Domain Admins" },
87     { DOMAIN_GROUP_RID_USERS        , "Domain Users" },
88     { DOMAIN_GROUP_RID_GUESTS       , "Domain Guests" },
89     { 0                             , NULL }
90 };
91
92
93 int make_dom_gids(DOMAIN_GRP *mem, int num_members, DOM_GID **ppgids)
94 {
95         int count;
96         int i;
97         DOM_GID *gids = NULL;
98
99         *ppgids = NULL;
100
101         DEBUG(4,("make_dom_gids: %d\n", num_members));
102
103         if (mem == NULL || num_members == 0)
104         {
105                 return 0;
106         }
107
108         for (i = 0, count = 0; i < num_members && count < LSA_MAX_GROUPS; i++) 
109         {
110                 uint32 status;
111
112                 uint32 rid;
113                 uint8  type;
114
115                 uint8  attr  = mem[count].attr;
116                 char   *name = mem[count].name;
117
118                 become_root(True);
119                 status = lookup_grp_rid(name, &rid, &type);
120                 unbecome_root(True);
121
122                 if (status == 0x0)
123                 {
124                         gids = (DOM_GID *)Realloc( gids, sizeof(DOM_GID) * (count+1) );
125
126                         if (gids == NULL)
127                         {
128                                 DEBUG(0,("make_dom_gids: Realloc fail !\n"));
129                                 return 0;
130                         }
131
132                         gids[count].g_rid = rid;
133                         gids[count].attr  = attr;
134
135                         DEBUG(5,("group name: %s rid: %d attr: %d\n",
136                                   name, rid, attr));
137                         count++;
138                 }
139                 else
140                 {
141                         DEBUG(1,("make_dom_gids: unknown group name %s\n", name));
142                 }
143         }
144
145         *ppgids = gids;
146         return count;
147 }
148
149 /*******************************************************************
150  gets a domain user's groups
151  ********************************************************************/
152 int get_domain_user_groups(DOMAIN_GRP_MEMBER **grp_members, uint32 group_rid)
153 {
154         DOMAIN_GRP *grp;
155         int num_mem;
156
157         if (grp_members == NULL) return 0;
158
159         grp = getgrouprid(group_rid, grp_members, &num_mem);
160
161         if (grp == NULL)
162         {
163                 return 0;
164         }
165
166         return num_mem;
167 }
168
169
170 /*******************************************************************
171  lookup_builtin_names
172  ********************************************************************/
173 uint32 lookup_builtin_names(DOM_SID *sid, char *name, uint8 *type)
174 {
175         uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED;
176
177         status = (status != 0x0) ? lookup_wk_user_name (sid, name, type) : status;
178         status = (status != 0x0) ? lookup_wk_group_name(sid, name, type) : status;
179         status = (status != 0x0) ? lookup_wk_alias_name(sid, name, type) : status;
180
181         return status;
182 }
183
184
185 /*******************************************************************
186  lookup_added_name - names that have been added to the SAM database by admins.
187  ********************************************************************/
188 uint32 lookup_added_name(DOM_SID *sid, char *name, uint8 *type)
189 {
190         uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED;
191
192         status = (status != 0x0) ? lookup_user_name (sid, name, type) : status;
193         status = (status != 0x0) ? lookup_group_name(sid, name, type) : status;
194         status = (status != 0x0) ? lookup_alias_name(sid, name, type) : status;
195
196         return status;
197 }
198
199
200 /*******************************************************************
201  lookup_name
202  ********************************************************************/
203 uint32 lookup_name(DOM_SID *sid, char *name, uint8 *type)
204 {
205         uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED;
206
207         status = (status != 0x0) ? lookup_builtin_names(sid, name, type) : status;
208         status = (status != 0x0) ? lookup_added_name   (sid, name, type) : status;
209
210         return status;
211 }
212
213
214 /*******************************************************************
215  lookup_wk_group_name
216  ********************************************************************/
217 uint32 lookup_wk_group_name(DOM_SID *sid, char *group_name, uint8 *type)
218 {
219         int i = 0; 
220         uint32 rid;
221         DOM_SID tmp;
222
223         (*type) = SID_NAME_WKN_GRP;
224
225         sid_copy(&tmp, sid);
226         sid_split_rid(&tmp, &rid);
227
228         if (!sid_equal(&global_sid_S_1_5_20, &tmp))
229         {
230                 return 0xC0000000 | NT_STATUS_NONE_MAPPED;
231         }
232
233         DEBUG(5,("lookup_wk_group_name: rid: %d", rid));
234
235         while (domain_group_rids[i].rid != rid && domain_group_rids[i].rid != 0)
236         {
237                 i++;
238         }
239
240         if (domain_group_rids[i].rid != 0)
241         {
242                 fstrcpy(group_name, domain_group_rids[i].name);
243                 DEBUG(5,(" = %s\n", group_name));
244                 return 0x0;
245         }
246
247         DEBUG(5,(" none mapped\n"));
248         return 0xC0000000 | NT_STATUS_NONE_MAPPED;
249 }
250
251 /*******************************************************************
252  lookup_group_name
253  ********************************************************************/
254 uint32 lookup_group_name(DOM_SID *sid, char *group_name, uint8 *type)
255 {
256         uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED;
257         uint32 rid;
258         DOM_SID tmp;
259
260         (*type) = SID_NAME_DOM_GRP;
261
262         sid_copy(&tmp, sid);
263         sid_split_rid(&tmp, &rid);
264
265         if (!sid_equal(&global_sid_S_1_5_20, &tmp))
266         {
267                 return status;
268         }
269
270         DEBUG(5,("lookup_group_name: rid: 0x%x", rid));
271
272         if (map_group_sid_to_name(sid, group_name, NULL))
273         {
274                 status = 0x0;
275         }
276
277         if (status == 0x0)
278         {
279                 DEBUG(5,(" = %s\n", group_name));
280         }
281         else
282         {
283                 DEBUG(5,(" none mapped\n"));
284         }
285
286         return status;
287 }
288
289 /*******************************************************************
290  lookup_wk_alias_name
291  ********************************************************************/
292 uint32 lookup_wk_alias_name(DOM_SID *sid, char *alias_name, uint8 *type)
293 {
294         int i = 0; 
295         uint32 rid;
296         DOM_SID tmp;
297
298         (*type) = SID_NAME_ALIAS;
299
300         sid_copy(&tmp, sid);
301         sid_split_rid(&tmp, &rid);
302
303         if (!sid_equal(&global_sid_S_1_5_20, &tmp))
304         {
305                 return 0xC0000000 | NT_STATUS_NONE_MAPPED;
306         }
307
308         DEBUG(5,("lookup_wk_alias_name: rid: %d", rid));
309
310         while (builtin_alias_rids[i].rid != rid && builtin_alias_rids[i].rid != 0)
311         {
312                 i++;
313         }
314
315         if (builtin_alias_rids[i].rid != 0)
316         {
317                 fstrcpy(alias_name, builtin_alias_rids[i].name);
318                 DEBUG(5,(" = %s\n", alias_name));
319                 return 0x0;
320         }
321
322         DEBUG(5,(" none mapped\n"));
323         return 0xC0000000 | NT_STATUS_NONE_MAPPED;
324 }
325
326 /*******************************************************************
327  lookup_alias_name
328  ********************************************************************/
329 uint32 lookup_alias_name(DOM_SID *sid, char *alias_name, uint8 *type)
330 {
331         fstring sid_str;
332         (*type) = SID_NAME_ALIAS;
333
334         sid_to_string(sid_str, sid);
335
336         DEBUG(2,("lookup_alias_name: sid: %s\n", sid_str));
337         DEBUG(2,(" NOT IMPLEMENTED\n"));
338
339         return 0xC0000000 | NT_STATUS_NONE_MAPPED;
340 }
341
342 /*******************************************************************
343  lookup well-known user name
344  ********************************************************************/
345 uint32 lookup_wk_user_name(DOM_SID *sid, char *user_name, uint8 *type)
346 {
347         int i = 0;
348         uint32 rid;
349         DOM_SID tmp;
350
351         (*type) = SID_NAME_USER;
352
353         sid_copy(&tmp, sid);
354         sid_split_rid(&tmp, &rid);
355
356         if (!sid_equal(&global_sid_S_1_5_20, &tmp))
357         {
358                 return 0xC0000000 | NT_STATUS_NONE_MAPPED;
359         }
360
361         DEBUG(5,("lookup_wk_user_name: rid: %d", rid));
362
363         /* look up the well-known domain user rids first */
364         while (domain_user_rids[i].rid != rid && domain_user_rids[i].rid != 0)
365         {
366                 i++;
367         }
368
369         if (domain_user_rids[i].rid != 0)
370         {
371                 fstrcpy(user_name, domain_user_rids[i].name);
372                 DEBUG(5,(" = %s\n", user_name));
373                 return 0x0;
374         }
375
376         DEBUG(5,(" none mapped\n"));
377         return 0xC0000000 | NT_STATUS_NONE_MAPPED;
378 }
379
380 /*******************************************************************
381  lookup user name
382  ********************************************************************/
383 uint32 lookup_user_name(DOM_SID *sid, char *user_name, uint8 *type)
384 {
385         struct sam_disp_info *disp_info;
386         uint32 rid;
387         DOM_SID tmp;
388
389         (*type) = SID_NAME_USER;
390
391         sid_copy(&tmp, sid);
392         sid_split_rid(&tmp, &rid);
393
394         if (sid_equal(&global_sam_sid, &tmp))
395         {
396                 DEBUG(5,("lookup_user_name in SAM %s: rid: %d",
397                           global_sam_name, rid));
398
399                 /* find the user account */
400                 become_root(True);
401                 disp_info = getsamdisprid(rid);
402                 unbecome_root(True);
403
404                 if (disp_info != NULL)
405                 {
406                         fstrcpy(user_name, disp_info->smb_name);
407                         DEBUG(5,(" = %s\n", user_name));
408                         return 0x0;
409                 }
410
411                 DEBUG(5,(" none mapped\n"));
412         }
413
414         return 0xC0000000 | NT_STATUS_NONE_MAPPED;
415 }
416
417 /*******************************************************************
418  lookup_group_rid
419  ********************************************************************/
420 uint32 lookup_group_rid(char *group_name, uint32 *rid, uint8 *type)
421 {
422         DOM_SID sid;
423
424         (*rid) = 0;
425         (*type) = SID_NAME_DOM_GRP;
426
427         DEBUG(5,("lookup_group_rid: name: %s", group_name));
428
429         if (map_group_name_to_sid(group_name, &sid) &&
430             sid_split_rid(&sid, rid) &&
431             sid_equal(&sid, &global_sam_sid))
432         {
433                 DEBUG(5,(" = 0x%x\n", (*rid)));
434                 return 0x0;
435         }
436
437         DEBUG(5,(" none mapped\n"));
438         return 0xC0000000 | NT_STATUS_NONE_MAPPED;
439 }
440
441 /*******************************************************************
442  lookup_wk_group_rid
443  ********************************************************************/
444 uint32 lookup_wk_group_rid(char *group_name, uint32 *rid, uint8 *type)
445 {
446         char *grp_name;
447         int i = -1; /* start do loop at -1 */
448         (*rid) = 0;
449         (*type) = SID_NAME_WKN_GRP;
450
451         do /* find, if it exists, a group rid for the group name */
452         {
453                 i++;
454                 (*rid) = domain_group_rids[i].rid;
455                 grp_name = domain_group_rids[i].name;
456
457         } while (grp_name != NULL && !strequal(grp_name, group_name));
458
459         return (grp_name != NULL) ? 0 : 0xC0000000 | NT_STATUS_NONE_MAPPED;
460 }
461
462 /*******************************************************************
463  lookup_alias_sid
464  ********************************************************************/
465 uint32 lookup_alias_sid(char *alias_name, DOM_SID *sid, uint8 *type)
466 {
467         (*type) = SID_NAME_ALIAS;
468
469         DEBUG(5,("lookup_alias_rid: name: %s", alias_name));
470
471         if (map_alias_name_to_sid(alias_name, sid))
472         {
473                 fstring sid_str;
474                 sid_to_string(sid_str, sid);
475                 DEBUG(5,(" = %s\n", sid_str));
476                 return 0x0;
477         }
478
479         DEBUG(5,(" none mapped\n"));
480         return 0xC0000000 | NT_STATUS_NONE_MAPPED;
481 }
482
483 /*******************************************************************
484  lookup_alias_rid
485  ********************************************************************/
486 uint32 lookup_alias_rid(char *alias_name, uint32 *rid, uint8 *type)
487 {
488         DOM_SID sid;
489
490         (*rid) = 0;
491         (*type) = SID_NAME_ALIAS;
492
493         DEBUG(5,("lookup_alias_rid: name: %s", alias_name));
494
495         if (map_alias_name_to_sid(alias_name, &sid) &&
496             sid_split_rid(&sid, rid) &&
497             sid_equal(&sid, &global_sam_sid))
498         {
499                 DEBUG(5,(" = 0x%x\n", (*rid)));
500                 return 0x0;
501         }
502
503         DEBUG(5,(" none mapped\n"));
504         return 0xC0000000 | NT_STATUS_NONE_MAPPED;
505 }
506
507 /*******************************************************************
508  lookup_wk_alias_sid
509  ********************************************************************/
510 uint32 lookup_wk_alias_sid(char *alias_name, DOM_SID *sid, uint8 *type)
511 {
512         char *als_name;
513         int i = 0;
514         uint32 rid;
515         (*type) = SID_NAME_ALIAS;
516
517         do /* find, if it exists, a alias rid for the alias name*/
518         {
519                 rid      = builtin_alias_rids[i].rid;
520                 als_name = builtin_alias_rids[i].name;
521
522                 i++;
523
524                 if (strequal(als_name, alias_name))
525                 {
526                         sid_copy(sid, &global_sid_S_1_5_20);
527                         sid_append_rid(sid, rid);
528
529                         return 0x0;
530                 }
531                         
532         } while (als_name != NULL);
533
534         return 0xC0000000 | NT_STATUS_NONE_MAPPED;
535 }
536
537 /*******************************************************************
538  lookup_wk_alias_rid
539  ********************************************************************/
540 uint32 lookup_wk_alias_rid(char *alias_name, uint32 *rid, uint8 *type)
541 {
542         char *als_name;
543         int i = -1; /* start do loop at -1 */
544         (*rid) = 0;
545         (*type) = SID_NAME_ALIAS;
546
547         do /* find, if it exists, a alias rid for the alias name*/
548         {
549                 i++;
550                 (*rid) = builtin_alias_rids[i].rid;
551                 als_name = builtin_alias_rids[i].name;
552
553         } while (als_name != NULL && !strequal(als_name, alias_name));
554
555         return (als_name != NULL) ? 0 : 0xC0000000 | NT_STATUS_NONE_MAPPED;
556 }
557
558 /*******************************************************************
559  lookup_sid
560  ********************************************************************/
561 uint32 lookup_sid(char *name, DOM_SID *sid, uint8 *type)
562 {
563         uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED;
564         fstring domain;
565         fstring user;
566         
567         split_domain_name(name, domain, user);
568
569         if (!strequal(domain, global_sam_name))
570         {
571                 DEBUG(0,("lookup_sid: remote domain %s not supported\n", domain));
572                 return status;
573         }
574
575         status = (status != 0x0) ? lookup_wk_alias_sid(user, sid, type) : status;
576         status = (status != 0x0) ? lookup_alias_sid   (user, sid, type) : status;
577 #if 0
578         status = (status != 0x0) ? lookup_domain_sid  (user, sid, type) : status;
579 #endif
580
581         return status;
582 }
583
584 /*******************************************************************
585  lookup_added_user_rid
586  ********************************************************************/
587 uint32 lookup_added_user_rids(char *user_name,
588                 uint32 *usr_rid, uint32 *grp_rid)
589 {
590         struct sam_passwd *sam_pass;
591         (*usr_rid) = 0;
592         (*grp_rid) = 0;
593
594         /* find the user account */
595         become_root(True);
596         sam_pass = getsam21pwnam(user_name);
597         unbecome_root(True);
598
599         if (sam_pass != NULL)
600         {
601                 (*usr_rid) = sam_pass->user_rid ;
602                 (*grp_rid) = sam_pass->group_rid;
603                 return 0x0;
604         }
605
606         return 0xC0000000 | NT_STATUS_NONE_MAPPED;
607 }
608
609 /*******************************************************************
610  lookup_added_user_rid
611  ********************************************************************/
612 uint32 lookup_added_user_rid(char *user_name, uint32 *rid, uint8 *type)
613 {
614         struct sam_passwd *sam_pass;
615         (*rid) = 0;
616         (*type) = SID_NAME_USER;
617
618         /* find the user account */
619         become_root(True);
620         sam_pass = getsam21pwnam(user_name);
621         unbecome_root(True);
622
623         if (sam_pass != NULL)
624         {
625                 (*rid) = sam_pass->user_rid;
626                 return 0x0;
627         }
628
629         return 0xC0000000 | NT_STATUS_NONE_MAPPED;
630 }
631
632 /*******************************************************************
633  lookup_wk_user_rid
634  ********************************************************************/
635 uint32 lookup_wk_user_rid(char *user_name, uint32 *rid, uint8 *type)
636 {
637         char *usr_name;
638         int i = -1; /* start do loop at -1 */
639         (*rid) = 0;
640         (*type) = SID_NAME_USER;
641
642         do /* find, if it exists, a alias rid for the alias name*/
643         {
644                 i++;
645                 (*rid) = domain_user_rids[i].rid;
646                 usr_name = domain_user_rids[i].name;
647
648         } while (usr_name != NULL && !strequal(usr_name, user_name));
649
650         return (usr_name != NULL) ? 0 : 0xC0000000 | NT_STATUS_NONE_MAPPED;
651 }
652
653 /*******************************************************************
654  lookup_added_grp_rid
655  ********************************************************************/
656 uint32 lookup_added_grp_rid(char *name, uint32 *rid, uint8 *type)
657 {
658         uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED;
659
660         status = (status != 0x0) ? lookup_group_rid(name, rid, type) : status;
661         status = (status != 0x0) ? lookup_alias_rid(name, rid, type) : status;
662
663         return status;
664 }
665
666 /*******************************************************************
667  lookup_builtin_grp_rid
668  ********************************************************************/
669 uint32 lookup_builtin_grp_rid(char *name, uint32 *rid, uint8 *type)
670 {
671         uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED;
672
673         status = (status != 0x0) ? lookup_wk_group_rid(name, rid, type) : status;
674         status = (status != 0x0) ? lookup_wk_alias_rid(name, rid, type) : status;
675
676         return status;
677 }
678
679 /*******************************************************************
680  lookup_grp_rid
681  ********************************************************************/
682 uint32 lookup_grp_rid(char *name, uint32 *rid, uint8 *type)
683 {
684         uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED;
685
686         status = (status != 0x0) ? lookup_builtin_grp_rid(name, rid, type) : status;
687         status = (status != 0x0) ? lookup_added_grp_rid  (name, rid, type) : status;
688
689         return status;
690 }
691
692 /*******************************************************************
693  lookup_user_rid
694  ********************************************************************/
695 uint32 lookup_user_rid(char *name, uint32 *rid, uint8 *type)
696 {
697         uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED;
698
699         status = (status != 0x0) ? lookup_wk_user_rid   (name, rid, type) : status;
700         status = (status != 0x0) ? lookup_added_user_rid(name, rid, type) : status;
701
702         return status;
703 }
704
705 /*******************************************************************
706  lookup_rid
707  ********************************************************************/
708 uint32 lookup_rid(char *name, uint32 *rid, uint8 *type)
709 {
710         uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED;
711
712         status = (status != 0x0) ? lookup_user_rid(name, rid, type) : status;
713         status = (status != 0x0) ? lookup_grp_rid (name, rid, type) : status;
714
715         return status;
716 }
717
718 /*******************************************************************
719  lookup_user_rids
720  ********************************************************************/
721 uint32 lookup_user_rids(char *name, uint32 *usr_rid, uint32 *grp_rid)
722 {
723         uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED;
724         uint8 type;
725
726         /*
727          * try an ordinary user lookup
728          */
729
730         status = lookup_added_user_rids(name, usr_rid, grp_rid);
731         if (status == 0)
732         {
733                 return status;
734         }
735
736         /*
737          * hm.  must be a well-known user, in a well-known group.
738          */
739
740         status = lookup_wk_user_rid(name, usr_rid, &type);
741         if (status != 0 || type != SID_NAME_USER)
742         {
743                 return status; /* ok, maybe not! */
744         }
745         if (type != SID_NAME_USER)
746         {
747                 return 0xC0000000 | NT_STATUS_NONE_MAPPED; /* users only... */
748         }
749
750         /*
751          * ok, got the user rid: now try the group rid
752          */
753
754         status = lookup_builtin_grp_rid(name, grp_rid, &type);
755         if (type == SID_NAME_DOM_GRP ||
756             type == SID_NAME_ALIAS ||
757             type == SID_NAME_WKN_GRP)
758         {
759                 status = 0xC0000000 | NT_STATUS_NONE_MAPPED;
760         }
761
762         return status;
763 }