KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > GetGroupMemberSidsFromURL


1 import java.util.*;
2 import jcifs.smb.*;
3
4 public class GetGroupMemberSidsFromURL {
5
6     public static void main( String JavaDoc[] argv ) throws Exception JavaDoc {
7         if (argv.length < 1) {
8             System.err.println("usage: GetGroupMemberSidsFromURL <smburl>");
9             System.exit(1);
10         }
11
12         SmbFile file = new SmbFile(argv[0]);
13         String JavaDoc server = file.getServer();
14         NtlmPasswordAuthentication auth = (NtlmPasswordAuthentication)file.getPrincipal();
15         ACE[] security = file.getSecurity(true);
16
17         for (int ai = 0; ai < security.length; ai++) {
18             ACE ace = security[ai];
19             SID sid = ace.getSID();
20             if (sid.equals(SID.EVERYONE) ||
21                         sid.equals(SID.CREATOR_OWNER) ||
22                         sid.equals(SID.SYSTEM))
23                 continue;
24
25             System.out.println(sid.toString() + " (" + sid.toDisplayString() + ") members:");
26
27             SID[] mems = sid.getGroupMemberSids(server, auth, SID.SID_FLAG_RESOLVE_SIDS);
28             for (int mi = 0; mi < mems.length; mi++) {
29                 SID mem = mems[mi];
30                 System.out.println(" " + mem.getType() + " " + mem.toDisplayString());
31             }
32         }
33     }
34 }
35
Popular Tags