java.lang.Object
org.codelibs.jcifs.smb.dcerpc.ndr.NdrObject
org.codelibs.jcifs.smb.dcerpc.rpc.sid_t
org.codelibs.jcifs.smb.impl.SID
- All Implemented Interfaces:
SID
Internal representation of SIDs
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
This section is intended for internal use.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic SIDWell known SID: CREATOR_OWNERstatic SIDWell known SID: EVERYONEstatic final intFlag indicating that SIDs should be resolved to names.static SIDWell known SID: SYSTEMFields inherited from class org.codelibs.jcifs.smb.dcerpc.rpc.sid_t
identifier_authority, revision, sub_authority, sub_authority_countFields inherited from interface org.codelibs.jcifs.smb.SID
SID_TYPE_ALIAS, SID_TYPE_DELETED, SID_TYPE_DOM_GRP, SID_TYPE_DOMAIN, SID_TYPE_INVALID, SID_TYPE_UNKNOWN, SID_TYPE_USE_NONE, SID_TYPE_USER, SID_TYPE_WKN_GRP -
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).Construct a relative SID -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturn the sAMAccountName of this SID unless it could not be resolved in which case the numeric RID is returned.Return the domain name of this SID unless it could not be resolved in which case the numeric representation is returned.Gets the domain SID for this SID.SID[]getGroupMemberSids(String authorityServerName, CIFSContext tc, int flags) Get members of the group represented by this SID, if it is one.intgetRid()Get the RID This is the last subauthority identifierintgetType()Returns the type of this SID indicating the state or type of account.Return text representing the SID type suitable for display to users.inthashCode()voidinitContext(String server, CIFSContext context) Initializes the context and server for this SID for deferred resolution.booleanisBlank()Checks whether the SID is blank (all sub-authorities zero).booleanisEmpty()Checks whether the SID is empty (no sub-authorities).voidresolve(String authorityServerName, CIFSContext tc) Manually resolve this SID.byte[]Gets the byte array representation of this SID.static byte[]toByteArray(rpc.sid_t sid) Convert a sid_t to byte arrayReturn a String representing this SID ideal for display to users.toString()Return the numeric representation of this sid such asS-1-5-21-1496946806-2192648263-3843101252-1029.<T> TUnwraps this SID to the specified type.
-
Field Details
-
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 -
CREATOR_OWNER
Well known SID: CREATOR_OWNER -
SYSTEM
Well known SID: SYSTEM
-
-
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). For example, a domain SIDS-1-5-21-1496946806-2192648263-3843101252and RID1029would yield the SIDS-1-5-21-1496946806-2192648263-3843101252-1029.- Parameters:
domsid- the domain SIDrid- the relative identifier
-
SID
Construct a relative SID- Parameters:
domsid- the domain SIDid- the SID to append to the domain SID
-
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
-
toByteArray
Convert a sid_t to byte array- Parameters:
sid- the RPC sid_t structure to convert- Returns:
- byte encoded form
-
unwrap
Unwraps this SID to the specified type. -
toByteArray
public byte[] toByteArray()Gets the byte array representation of this SID.- Returns:
- encoded SID
-
isEmpty
public boolean isEmpty()Checks whether the SID is empty (no sub-authorities).- Returns:
- whether the SID is empty (no sub-authorities)
-
isBlank
public boolean isBlank()Checks whether the SID is blank (all sub-authorities zero).- Returns:
- whether the SID is blank (all sub-authorities zero)
-
getDomainSid
Description copied from interface:SIDGets the domain SID for this SID.- Specified by:
getDomainSidin interfaceSID- Returns:
- domain SID
-
getRid
public int getRid()Get the RID This is the last subauthority identifier -
getType
public int getType()Description copied from interface:SIDReturns the type of this SID indicating the state or type of account.SID types are described in the following table.
Type codes Type Name SID_TYPE_USE_NONE 0 SID_TYPE_USER User SID_TYPE_DOM_GRP Domain group SID_TYPE_DOMAIN Domain SID_TYPE_ALIAS Local group SID_TYPE_WKN_GRP Builtin group SID_TYPE_DELETED Deleted SID_TYPE_INVALID Invalid SID_TYPE_UNKNOWN Unknown -
getTypeText
Description copied from interface:SIDReturn text representing the SID type suitable for display to users. Text includes 'User', 'Domain group', 'Local group', etc.- Specified by:
getTypeTextin interfaceSID- Returns:
- textual representation of type
-
getDomainName
Description copied from interface:SIDReturn the domain name of this SID unless it could not be resolved in which case the numeric representation is returned.- Specified by:
getDomainNamein interfaceSID- Returns:
- the domain name
-
getAccountName
Description copied from interface:SIDReturn the sAMAccountName of this SID unless it could not be resolved in which case the numeric RID is returned. If this SID is a domain SID, this method will return an empty String.- Specified by:
getAccountNamein interfaceSID- 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
Description copied from interface:SIDReturn a String representing this SID ideal for display to users. This method should return the same text that the ACL editor in Windows would display.Specifically, if the SID has been resolved and it is not a domain SID or builtin account, the full DOMAIN\name form of the account will be returned (e.g. MYDOM\alice or MYDOM\Domain Users). If the SID has been resolved but it is is a domain SID, only the domain name will be returned (e.g. MYDOM). If the SID has been resolved but it is a builtin account, only the name component will be returned (e.g. SYSTEM). If the sid cannot be resolved the numeric representation from toString() is returned.
- Specified by:
toDisplayStringin interfaceSID- Returns:
- display format, potentially with resolved names
-
resolve
Manually resolve this SID. Normally SIDs are automatically resolved. However, if a SID is constructed explicitly using a SID constructor, JCIFS will have no knowledge of the server that created the SID and therefore cannot possibly resolve it automatically. In this case, this method will be necessary.- Parameters:
authorityServerName- The FQDN of the server that is an authority for the SID.tc- Context to use- Throws:
IOException- if there is an error resolving the SID
-
getGroupMemberSids
public SID[] getGroupMemberSids(String authorityServerName, CIFSContext tc, int flags) throws IOException Get members of the group represented by this SID, if it is one.- Parameters:
authorityServerName- the server to use for SID resolutiontc- the CIFS context to useflags- resolution flags- Returns:
- the members of the group
- Throws:
IOException- if there is an error retrieving group members
-
initContext
Initializes the context and server for this SID for deferred resolution.- Parameters:
context- the CIFS context to useserver- the server name for SID resolution
-