java.lang.Object
org.codelibs.jcifs.smb1.dcerpc.ndr.NdrObject
org.codelibs.jcifs.smb1.dcerpc.rpc.sid_t
org.codelibs.jcifs.smb1.SID
A Windows SID is a numeric identifier used to represent Windows
accounts. SIDs are commonly represented using a textual format such as
S-1-5-21-1496946806-2192648263-3843101252-1029 but they may
also be resolved to yield the name of the associated Windows account
such as Administrators or MYDOM\alice.
Consider the following output of examples/SidLookup.java:
toString: S-1-5-21-4133388617-793952518-2001621813-512
toDisplayString: WNET\Domain Admins
getType: 2
getTypeText: Domain group
getDomainName: WNET
getAccountName: Domain Admins
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic SIDWell known SID: CREATOR_OWNER (S-1-3-0).static SIDWell known SID: EVERYONE (S-1-1-0).static final intFlag indicating that SIDs should be resolved to names.static final intSID type indicating a local group or alias.static final intSID type indicating a deleted account.static final intSID type indicating a domain group.static final intSID type indicating a domain.static final intSID type indicating an invalid SID.static final intSID type indicating an unknown account type.static final intSID type indicating no type information.static final intSID type indicating a user account.static final intSID type indicating a well-known group.static SIDWell known SID: SYSTEM (S-1-5-18).Fields inherited from class org.codelibs.jcifs.smb1.dcerpc.rpc.sid_t
identifier_authority, revision, sub_authority, sub_authority_count -
Constructor Summary
ConstructorsConstructorDescriptionSID(byte[] src, int si) Construct a SID from it's binary representation.Construct a SID from it's textual representation such asS-1-5-21-1496946806-2192648263-3843101252-1029.Constructs a SID from an RPC sid_t structure.Construct a SID from a domain SID and an RID (relative identifier). -
Method Summary
Modifier and TypeMethodDescriptionbooleanGets the account name for this SID.Gets the domain name for this SID.Gets the domain SID for this SID.SID[]getGroupMemberSids(String authorityServerName, NtlmPasswordAuthentication auth, int flags) Gets the members of the group represented by this SID.intgetRid()Gets the RID (relative identifier) of this SID.static SIDgetServerSid(String server, NtlmPasswordAuthentication auth) Gets the domain SID for the specified server.intgetType()Gets the type of this SID.Gets a textual representation of the SID type.inthashCode()voidresolve(String authorityServerName, NtlmPasswordAuthentication auth) Resolves this SID to obtain its account and domain names.static voidresolveSids(String authorityServerName, NtlmPasswordAuthentication auth, SID[] sids) Resolves an array of SIDs to obtain their account and domain names.static voidresolveSids(String authorityServerName, NtlmPasswordAuthentication auth, SID[] sids, int offset, int length) Resolves an array of SIDs to obtain their account and domain names.static byte[]toByteArray(rpc.sid_t sid) Converts an RPC sid_t structure to a byte array.Returns a string representation of this SID suitable for display to users.toString()Return the numeric representation of this sid such asS-1-5-21-1496946806-2192648263-3843101252-1029.
-
Field Details
-
SID_TYPE_USE_NONE
public static final int SID_TYPE_USE_NONESID type indicating no type information.- See Also:
-
SID_TYPE_USER
public static final int SID_TYPE_USERSID type indicating a user account.- See Also:
-
SID_TYPE_DOM_GRP
public static final int SID_TYPE_DOM_GRPSID type indicating a domain group.- See Also:
-
SID_TYPE_DOMAIN
public static final int SID_TYPE_DOMAINSID type indicating a domain.- See Also:
-
SID_TYPE_ALIAS
public static final int SID_TYPE_ALIASSID type indicating a local group or alias.- See Also:
-
SID_TYPE_WKN_GRP
public static final int SID_TYPE_WKN_GRPSID type indicating a well-known group.- See Also:
-
SID_TYPE_DELETED
public static final int SID_TYPE_DELETEDSID type indicating a deleted account.- See Also:
-
SID_TYPE_INVALID
public static final int SID_TYPE_INVALIDSID type indicating an invalid SID.- See Also:
-
SID_TYPE_UNKNOWN
public static final int SID_TYPE_UNKNOWNSID type indicating an unknown account type.- See Also:
-
SID_FLAG_RESOLVE_SIDS
public static final int SID_FLAG_RESOLVE_SIDSFlag indicating that SIDs should be resolved to names.- See Also:
-
EVERYONE
Well known SID: EVERYONE (S-1-1-0). -
CREATOR_OWNER
Well known SID: CREATOR_OWNER (S-1-3-0). -
SYSTEM
Well known SID: SYSTEM (S-1-5-18).
-
-
Constructor Details
-
SID
public SID(byte[] src, int si) Construct a SID from it's binary representation.- Parameters:
src- the byte array containing the SIDsi- the starting index in the array
-
SID
Construct a SID from it's textual representation such asS-1-5-21-1496946806-2192648263-3843101252-1029.- Parameters:
textual- the textual representation of the SID- Throws:
SmbException- if the textual format is invalid
-
SID
Construct a SID from a domain SID and an RID (relative identifier).- Parameters:
domsid- the domain SIDrid- the relative identifier
-
SID
Constructs a SID from an RPC sid_t structure.- Parameters:
sid- the RPC sid_t structuretype- the SID typedomainName- the domain name for this SIDacctName- the account name for this SIDdecrementAuthority- whether to decrement the authority count
-
-
Method Details
-
resolveSids
public static void resolveSids(String authorityServerName, NtlmPasswordAuthentication auth, SID[] sids, int offset, int length) throws IOException Resolves an array of SIDs to obtain their account and domain names.- Parameters:
authorityServerName- the server to use for SID resolutionauth- the authentication credentials to usesids- the array of SIDs to resolveoffset- the starting offset in the arraylength- the number of SIDs to resolve- Throws:
IOException- if there is an error resolving the SIDs
-
resolveSids
public static void resolveSids(String authorityServerName, NtlmPasswordAuthentication auth, SID[] sids) throws IOException Resolves an array of SIDs to obtain their account and domain names.- Parameters:
authorityServerName- the server to use for SID resolutionauth- the authentication credentials to usesids- the array of SIDs to resolve- Throws:
IOException- if there is an error resolving the SIDs
-
getServerSid
Gets the domain SID for the specified server.- Parameters:
server- the server nameauth- the authentication credentials to use- Returns:
- the domain SID for the server
- Throws:
IOException- if there is an error retrieving the server SID
-
toByteArray
Converts an RPC sid_t structure to a byte array.- Parameters:
sid- the RPC sid_t structure to convert- Returns:
- byte array representation of the SID
-
getDomainSid
Gets the domain SID for this SID.- Returns:
- domain SID
-
getRid
public int getRid()Gets the RID (relative identifier) of this SID.- Returns:
- the RID
-
getType
public int getType()Gets the type of this SID.- Returns:
- the SID type code
-
getTypeText
Gets a textual representation of the SID type.- Returns:
- textual representation of the SID type
-
getDomainName
Gets the domain name for this SID.- Returns:
- the domain name
-
getAccountName
Gets the account name for this SID.- Returns:
- the account name
-
hashCode
public int hashCode() -
equals
-
toString
Return the numeric representation of this sid such asS-1-5-21-1496946806-2192648263-3843101252-1029. -
toDisplayString
Returns a string representation of this SID suitable for display to users.- Returns:
- display string representation of the SID
-
resolve
Resolves this SID to obtain its account and domain names.- Parameters:
authorityServerName- the server to use for SID resolutionauth- the authentication credentials to use- Throws:
IOException- if there is an error resolving the SID
-
getGroupMemberSids
public SID[] getGroupMemberSids(String authorityServerName, NtlmPasswordAuthentication auth, int flags) throws IOException Gets the members of the group represented by this SID.- Parameters:
authorityServerName- the server to use for resolutionauth- the authentication credentials to useflags- resolution flags- Returns:
- array of SIDs representing group members
- Throws:
IOException- if there is an error retrieving group members
-