C# Class SharpCifs.Smb.Sid

A Windows SID is a numeric identifier used to represent Windows accounts.
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 
Inheritance: SharpCifs.Dcerpc.Rpc.SidT
ファイルを表示 Open project: brandonprry/Potato Class Usage Examples

Public Properties

Property Type Description
CreatorOwner Sid
Everyone Sid
SYSTEM Sid

Public Methods

Method Description
Equals ( object obj ) : bool
GetAccountName ( ) : string

Return the sAMAccountName of this SID unless it could not be resolved in which case the numeric RID is returned.

Return 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.

GetDomainName ( ) : string

Return the domain name of this SID unless it could not be resolved in which case the numeric representation is returned.

Return the domain name of this SID unless it could not be resolved in which case the numeric representation is returned.

GetDomainSid ( ) : Sid
GetGroupMemberSids ( string authorityServerName, NtlmPasswordAuthentication auth, int flags ) : SharpCifs.Smb.Sid[]
GetHashCode ( ) : int
GetRid ( ) : int
GetServerSid ( string server, NtlmPasswordAuthentication auth ) : Sid
GetType ( ) : int

Returns the type of this SID indicating the state or type of account.

Returns the type of this SID indicating the state or type of account.

SID types are described in the following table.

TypeName
SID_TYPE_USE_NONE0
SID_TYPE_USERUser
SID_TYPE_DOM_GRPDomain group
SID_TYPE_DOMAINDomain
SID_TYPE_ALIASLocal group
SID_TYPE_WKN_GRPBuiltin group
SID_TYPE_DELETEDDeleted
SID_TYPE_INVALIDInvalid
SID_TYPE_UNKNOWNUnknown
GetTypeText ( ) : string

Return text represeting the SID type suitable for display to users.

Return text represeting the SID type suitable for display to users. Text includes 'User', 'Domain group', 'Local group', etc.

Resolve ( string authorityServerName, NtlmPasswordAuthentication auth ) : void

Manually resolve this SID.

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.

ResolveSids ( string authorityServerName, NtlmPasswordAuthentication auth, Sid sids ) : void

Resolve an array of SIDs using a cache and at most one MSRPC request.

Resolve an array of SIDs using a cache and at most one MSRPC request.

This method will attempt to resolve SIDs using a cache and cache the results of any SIDs that required resolving with the authority. SID cache entries are currently not expired because under normal circumstances SID information never changes.

ResolveSids ( string authorityServerName, NtlmPasswordAuthentication auth, Sid sids, int offset, int length ) : void
Sid ( Rpc sid, int type, string domainName, string acctName, bool decrementAuthority ) : System
Sid ( Sid domsid, int rid ) : System

Construct a SID from a domain SID and an RID (relative identifier).

Construct a SID from a domain SID and an RID (relative identifier). For example, a domain SID S-1-5-21-1496946806-2192648263-3843101252 and RID 1029 would yield the SID S-1-5-21-1496946806-2192648263-3843101252-1029.

Sid ( byte src, int si ) : System
Sid ( string textual ) : System

Construct a SID from it's textual representation such as S-1-5-21-1496946806-2192648263-3843101252-1029.

Construct a SID from it's textual representation such as S-1-5-21-1496946806-2192648263-3843101252-1029.

ToByteArray ( Rpc sid ) : byte[]
ToDisplayString ( ) : string

Return a String representing this SID ideal for display to users.

Return 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.

ToString ( ) : string

Return the numeric representation of this sid such as S-1-5-21-1496946806-2192648263-3843101252-1029.

Return the numeric representation of this sid such as S-1-5-21-1496946806-2192648263-3843101252-1029.

Private Methods

Method Description
GetGroupMemberSids0 ( DcerpcHandle handle, SamrDomainHandle domainHandle, Sid domsid, int rid, int flags ) : SharpCifs.Smb.Sid[]
GetLocalGroupsMap ( string authorityServerName, NtlmPasswordAuthentication auth, int flags ) : SharpCifs.Util.Sharpen.Hashtable

This specialized method returns a Map of users and local groups for the target server where keys are SIDs representing an account and each value is an List of SIDs represents the local groups that the account is a member of.

This specialized method returns a Map of users and local groups for the target server where keys are SIDs representing an account and each value is an List of SIDs represents the local groups that the account is a member of.

This method is designed to assist with computing access control for a given user when the target object's ACL has local groups. Local groups are not listed in a user's group membership (e.g. as represented by the tokenGroups constructed attribute retrived via LDAP).

Domain groups nested inside a local group are currently not expanded. In this case the key (SID) type will be SID_TYPE_DOM_GRP rather than SID_TYPE_USER.

ResolveSids ( DcerpcHandle handle, LsaPolicyHandle policyHandle, Sid sids ) : void
ResolveSids0 ( string authorityServerName, NtlmPasswordAuthentication auth, Sid sids ) : void
ResolveWeak ( ) : void
Sid ( ) : System

Method Details

Equals() public method

public Equals ( object obj ) : bool
obj object
return bool

GetAccountName() public method

Return the sAMAccountName of this SID unless it could not be resolved in which case the numeric RID is returned.
Return 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.
public GetAccountName ( ) : string
return string

GetDomainName() public method

Return the domain name of this SID unless it could not be resolved in which case the numeric representation is returned.
Return the domain name of this SID unless it could not be resolved in which case the numeric representation is returned.
public GetDomainName ( ) : string
return string

GetDomainSid() public method

public GetDomainSid ( ) : Sid
return Sid

GetGroupMemberSids() public method

public GetGroupMemberSids ( string authorityServerName, NtlmPasswordAuthentication auth, int flags ) : SharpCifs.Smb.Sid[]
authorityServerName string
auth NtlmPasswordAuthentication
flags int
return SharpCifs.Smb.Sid[]

GetHashCode() public method

public GetHashCode ( ) : int
return int

GetRid() public method

public GetRid ( ) : int
return int

GetServerSid() public static method

public static GetServerSid ( string server, NtlmPasswordAuthentication auth ) : Sid
server string
auth NtlmPasswordAuthentication
return Sid

GetType() public method

Returns the type of this SID indicating the state or type of account.
Returns the type of this SID indicating the state or type of account.

SID types are described in the following table.

TypeName
SID_TYPE_USE_NONE0
SID_TYPE_USERUser
SID_TYPE_DOM_GRPDomain group
SID_TYPE_DOMAINDomain
SID_TYPE_ALIASLocal group
SID_TYPE_WKN_GRPBuiltin group
SID_TYPE_DELETEDDeleted
SID_TYPE_INVALIDInvalid
SID_TYPE_UNKNOWNUnknown
public GetType ( ) : int
return int

GetTypeText() public method

Return text represeting the SID type suitable for display to users.
Return text represeting the SID type suitable for display to users. Text includes 'User', 'Domain group', 'Local group', etc.
public GetTypeText ( ) : string
return string

Resolve() public method

Manually resolve this SID.
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.
public Resolve ( string authorityServerName, NtlmPasswordAuthentication auth ) : void
authorityServerName string The FQDN of the server that is an authority for the SID. ///
auth NtlmPasswordAuthentication Credentials suitable for accessing the SID's information.
return void

ResolveSids() public static method

Resolve an array of SIDs using a cache and at most one MSRPC request.
Resolve an array of SIDs using a cache and at most one MSRPC request.

This method will attempt to resolve SIDs using a cache and cache the results of any SIDs that required resolving with the authority. SID cache entries are currently not expired because under normal circumstances SID information never changes.

public static ResolveSids ( string authorityServerName, NtlmPasswordAuthentication auth, Sid sids ) : void
authorityServerName string The hostname of the server that should be queried. For maximum efficiency this should be the hostname of a domain controller however a member server will work as well and a domain controller may not return names for SIDs corresponding to local accounts for which the domain controller is not an authority. ///
auth NtlmPasswordAuthentication The credentials that should be used to communicate with the named server. As usual, null indicates that default credentials should be used. ///
sids Sid The SIDs that should be resolved. After this function is called, the names associated with the SIDs may be queried with the toDisplayString, getDomainName, and getAccountName methods. ///
return void

ResolveSids() public static method

public static ResolveSids ( string authorityServerName, NtlmPasswordAuthentication auth, Sid sids, int offset, int length ) : void
authorityServerName string
auth NtlmPasswordAuthentication
sids Sid
offset int
length int
return void

Sid() public method

public Sid ( Rpc sid, int type, string domainName, string acctName, bool decrementAuthority ) : System
sid Rpc
type int
domainName string
acctName string
decrementAuthority bool
return System

Sid() public method

Construct a SID from a domain SID and an RID (relative identifier).
Construct a SID from a domain SID and an RID (relative identifier). For example, a domain SID S-1-5-21-1496946806-2192648263-3843101252 and RID 1029 would yield the SID S-1-5-21-1496946806-2192648263-3843101252-1029.
public Sid ( Sid domsid, int rid ) : System
domsid Sid
rid int
return System

Sid() public method

public Sid ( byte src, int si ) : System
src byte
si int
return System

Sid() public method

Construct a SID from it's textual representation such as S-1-5-21-1496946806-2192648263-3843101252-1029.
Construct a SID from it's textual representation such as S-1-5-21-1496946806-2192648263-3843101252-1029.
public Sid ( string textual ) : System
textual string
return System

ToByteArray() public static method

public static ToByteArray ( Rpc sid ) : byte[]
sid Rpc
return byte[]

ToDisplayString() public method

Return a String representing this SID ideal for display to users.
Return 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.

public ToDisplayString ( ) : string
return string

ToString() public method

Return the numeric representation of this sid such as S-1-5-21-1496946806-2192648263-3843101252-1029.
Return the numeric representation of this sid such as S-1-5-21-1496946806-2192648263-3843101252-1029.
public ToString ( ) : string
return string

Property Details

CreatorOwner public_oe static_oe property

public static Sid,SharpCifs.Smb CreatorOwner
return Sid

Everyone public_oe static_oe property

public static Sid,SharpCifs.Smb Everyone
return Sid

SYSTEM public_oe static_oe property

public static Sid,SharpCifs.Smb SYSTEM
return Sid