c# - Why does DirectoryEntry("WinNT://") not show group everyone? -


the below function (is supposed to) lists groups on local machine.
question: why "everyone" group not show ?
if change directory permissions user, see "everyone" group, must there, somewhere.

    public shared function getallgroups() datatable         return getallgroups(system.environment.machinename)     end function       ' tools.permissions.local.getallgroups() '     public shared function getallgroups(byval strdomain string) datatable         dim dt new datatable         dim dr datarow = nothing          try             dim bexception boolean = false             dim delocalmachine system.directoryservices.directoryentry = new system.directoryservices.directoryentry("winnt://" + strdomain)             'dim derootobject system.directoryservices.directoryentry = getdirectoryentry(strpath, strusername, strpassword, bexception) '             if bexception                 return nothing             end if               each child system.directoryservices.directoryentry in delocalmachine.children                 try                      if stringcomparer.ordinalignorecase.equals(child.schemaclassname, "group")                          if not dt.columns.contains("members")                             dt.columns.add("members", gettype(system.string))                         end if                          each strpropertyname string in child.properties.propertynames                             if not dt.columns.contains(strpropertyname)                                 dt.columns.add(strpropertyname, gettype(system.string))                             end if                         next strpropertyname                          dr = dt.newrow                          dim strmembers string = ""                         each member object in directcast(child.invoke("members"), ienumerable)                             using memberentry new system.directoryservices.directoryentry(member)                                  try                                     strmembers += memberentry.properties("name").value.tostring() + environment.newline                                     console.writeline(memberentry.path)                                 catch exfixmeisnotnullnotworking exception                                  end try                              end using                         next                          dr("members") = strmembers                          each strpropertyname string in child.properties.propertynames                              if stringcomparer.ordinalignorecase.equals(strpropertyname, "objectsid")                                 dim strsid string = ""                                 try                                     dim sidthissid new system.security.principal.securityidentifier(child.properties(strpropertyname).value, 0)                                     strsid = sidthissid.tostring()                                     ' http://stackoverflow.com/questions/1040623/convert-a-username-to-a-sid-string-in-c-net '                                     '  ntaccount ntaccount = (ntaccount)sid.translate( typeof( ntaccount ) ); '                                     ' dim ntaccount security.principal.ntaccount = ctype(sidthissid.translate(gettype(security.principal.ntaccount)), security.principal.ntaccount) '                                 catch ex exception                                  end try                                  dr(strpropertyname) = strsid                             else                                 dr(strpropertyname) = child.properties(strpropertyname).value.tostring()                             end if                            next strpropertyname                         dt.rows.add(dr)                      end if                  catch ex exception ' don't finish because 1 fails                     console.writeline(ex.message.tostring & vblf & vblf & ex.stacktrace.tostring, msgboxstyle.critical, "fehler ...")                 end try             next         catch ex exception             console.writeline(ex.message.tostring & vblf & vblf & ex.stacktrace.tostring, msgboxstyle.critical, "fehler ...")         end try          return dt     end function ' listeverything 

the everyone group isn't standard group rather implicit group or built-in principal. if open local "users , groups" won't see listed there either. same true of other "groups" such authenticated users. if want access these need use system.security.principal.wellknownsidtype enumeration. windows 2008 article relevant older versions of windows, too.


Comments