AcUtils
A high performance abstraction layer for AccuRev
Public Member Functions | Internal Functions | Properties | List of all members
AcUtils.AcUser Class Reference

A user's AccuRev principal attributes name, ID, and status (active or inactive). In addition, the user's AccuRev group membership list along with regular and other user properties from Active Directory can be included (both optional) during list construction. More...

Collaboration diagram for AcUtils.AcUser:
Collaboration graph
[legend]

Public Member Functions

string ToString (string format, IFormatProvider provider)
 The ToString implementation. More...
 
string getGroups ()
 Get the list of groups this user is a member of as a formatted string. List optionally initialized by AcUsers constructor when includeGroupsList param is true. More...
 
Equality comparison
bool Equals (AcUser other)
 IEquatable implementation to determine the equality of instances of type AcUser. Uses the user's principal ID to compare instances as this number is immutable in AccuRev; a user's principal attributes can change except their ID. More...
 
override bool Equals (object other)
 Overridden to determine equality. More...
 
override int GetHashCode ()
 Override appropriate for type AcUser. More...
 

Internal Functions

 AcUser (int id, string name, PrinStatus status)
 Initialize user's AccuRev principal attributes name, ID, and status (active or inactive). AcUser objects are instantiated during AcUsers list construction. This constructor is called internally and not by user code. More...
 
async Task< bool > initFromADAsync (DomainCollection dc, PropCollection pc=null)
 Optionally called during list construction to initialize the default set of regular user properties and others from Active Directory. This method is called internally and not by user code. More...
 
async Task< bool > initGroupsListAsync ()
 Optionally called during list construction to initialize the list of groups this user is a member of by way of direct or indirect (implicit) membership, e.g. Mary is implicitly a member of groupA because she's a member of groupB which is a member of groupA. This method is called internally and not by user code. More...
 

Properties

AcPrincipal Principal [get]
 AccuRev principal attributes name, ID, and status (active or inactive), and optionally their group membership list as per AcUsers constructor includeGroupsList parameter. More...
 
IDictionary< string, object > Other [get]
 Additional Active Directory user properties not in the regular default set. More...
 
User properties default set (Active Directory)
string GivenName [get]
 User's given name from Active Directory, e.g. John More...
 
string MiddleName [get]
 User's middle name from Active Directory. More...
 
string Surname [get]
 User's surname from Active Directory, e.g. Doe More...
 
string DisplayName [get]
 User's display name from Active Directory, e.g. Doe, John More...
 
string Business [get]
 User's business phone number from Active Directory. More...
 
string EmailAddress [get]
 User's email address from Active Directory. More...
 
string Description [get]
 User's description from Active Directory. More...
 
string DistinguishedName [get]
 User's distinguished name from Active Directory. More...
 

Order comparison

int CompareTo (AcUser other)
 Generic IComparable implementation (default) for comparing AcUser objects to sort by DisplayName from Active Directory if available, otherwise their AccuRev principal name. More...
 
int IComparable. CompareTo (object other)
 Pre-generic interface implementation for code using reflection. More...
 

Detailed Description

A user's AccuRev principal attributes name, ID, and status (active or inactive). In addition, the user's AccuRev group membership list along with regular and other user properties from Active Directory can be included (both optional) during list construction.

Attention
User properties require that AccuRev principal names match login names stored on the LDAP server.

Definition at line 37 of file AcUsers.cs.

Constructor & Destructor Documentation

AcUtils.AcUser.AcUser ( int  id,
string  name,
PrinStatus  status 
)
inlinepackage

Initialize user's AccuRev principal attributes name, ID, and status (active or inactive). AcUser objects are instantiated during AcUsers list construction. This constructor is called internally and not by user code.

Parameters
idUser's AccuRev principal ID number.
nameUser's AccuRev principal name.
statusWhether the user is active or inactive in AccuRev.
See also
AcUsers.initAsync, AcUser.initFromADAsync, AcUser.initGroupsListAsync

Definition at line 62 of file AcUsers.cs.

Referenced by AcUtils.AcUser.CompareTo().

Member Function Documentation

int AcUtils.AcUser.CompareTo ( AcUser  other)
inline

Generic IComparable implementation (default) for comparing AcUser objects to sort by DisplayName from Active Directory if available, otherwise their AccuRev principal name.

Parameters
otherAn AcUser object to compare with this instance.
Returns
Value indicating the relative order of the AcUser objects being compared.
See also
AcUsers constructor example

Definition at line 119 of file AcUsers.cs.

Referenced by AcUtils.AcUser.CompareTo().

int IComparable. AcUtils.AcUser.CompareTo ( object  other)
inlineprivate

Pre-generic interface implementation for code using reflection.

Parameters
otherAn AcUser object to compare with this instance.
Returns
Return value of generic CompareTo(AcUser) version.
Exceptions
ArgumentExceptionthrown if argument is not an AcUser object.

Definition at line 141 of file AcUsers.cs.

bool AcUtils.AcUser.Equals ( AcUser  other)
inline

IEquatable implementation to determine the equality of instances of type AcUser. Uses the user's principal ID to compare instances as this number is immutable in AccuRev; a user's principal attributes can change except their ID.

Parameters
otherThe AcUser object being compared to this instance.
Returns
true if AcUser rhs is the same, false otherwise.

Definition at line 79 of file AcUsers.cs.

Referenced by AcUtils.AcUser.Equals().

override bool AcUtils.AcUser.Equals ( object  other)
inline

Overridden to determine equality.

Returns
Return value of generic Equals(AcUser) version.

Definition at line 90 of file AcUsers.cs.

string AcUtils.AcUser.getGroups ( )
inline

Get the list of groups this user is a member of as a formatted string. List optionally initialized by AcUsers constructor when includeGroupsList param is true.

Returns
User's group membership list as an ordered formatted comma-delimited string, otherwise null if not found.
See also
AcGroups.isMember, AcGroups.getMembers

Definition at line 476 of file AcUsers.cs.

override int AcUtils.AcUser.GetHashCode ( )
inline

Override appropriate for type AcUser.

Returns
AccuRev principal ID number since it's immutable and unique across both users and groups.

Definition at line 102 of file AcUsers.cs.

async Task<bool> AcUtils.AcUser.initFromADAsync ( DomainCollection  dc,
PropCollection  pc = null 
)
inlinepackage

Optionally called during list construction to initialize the default set of regular user properties and others from Active Directory. This method is called internally and not by user code.

Parameters
dcList of DomainElement objects as defined in <prog_name>.exe.config domains section. Used to initialize the user properties default set from Active Directory.
pcList of PropElement objects as defined in <prog_name>.exe.config properties section. Used to add and initialize user properties from Active Directory that are outside the regular default set.
Returns
true if no exception was thrown and operation succeeded, false otherwise.
Exceptions
Exceptioncaught and logged in %LOCALAPPDATA%\AcTools\Logs\<prog_name>-YYYY-MM-DD.log on failure to handle a range of exceptions.
See also
DomainCollection, PropCollection, Other
Attention
User properties require that AccuRev principal names match login names stored on the LDAP server.

Definition at line 361 of file AcUsers.cs.

Referenced by AcUtils.AcUsers.initUserPropsAsync().

async Task<bool> AcUtils.AcUser.initGroupsListAsync ( )
inlinepackage

Optionally called during list construction to initialize the list of groups this user is a member of by way of direct or indirect (implicit) membership, e.g. Mary is implicitly a member of groupA because she's a member of groupB which is a member of groupA. This method is called internally and not by user code.

Membership lists for inactive users are initialized too when constructor parameter includeDeactivated is true.

Returns
true if no exception was thrown and operation succeeded, false otherwise.
Exceptions
AcUtilsExceptioncaught and logged in %LOCALAPPDATA%\AcTools\Logs\<prog_name>-YYYY-MM-DD.log on show command failure.
Exceptioncaught and logged in same on failure to handle a range of exceptions.
See also
AcGroups.initMembersListAsync
show command:
show -fx -u <user> groups
AccuNote:
Unlike the show command used here, its show -fx -g <group> members counterpart does not include memberships resulting from indirect (implicit) membership.

Definition at line 434 of file AcUsers.cs.

Referenced by AcUtils.AcUsers.initUserPropsAsync().

string AcUtils.AcUser.ToString ( string  format,
IFormatProvider  provider 
)
inline

The ToString implementation.

Parameters
formatThe format specifier to use, e.g. Console.WriteLine(user.ToString("e"));
providerAllow clients to format output for their own types using ICustomFormatter.
Returns
The formatted string.
Exceptions
FormatExceptionthrown if an invalid format string is specified.
Format specifiers:
  • G User's display name from Active Directory if available (e.g. Doe, John), otherwise their AccuRev principal name. The default when no format specifier is used.
  • LV Long version (verbose).
  • I User's AccuRev principal ID number.
  • N User's AccuRev principal name.
  • S Principal's status in AccuRev: Active or Inactive.
  • F User's given name from Active Directory.
  • M User's middle name from Active Directory.
  • L User's surname from Active Directory.
  • DN User's display name from Active Directory.
  • B User's business phone number from Active Directory.
  • E User's email address from Active Directory.
  • D User's description from Active Directory.
  • DG User's distinguished name from Active Directory.

Definition at line 289 of file AcUsers.cs.

Property Documentation

string AcUtils.AcUser.Business
get

User's business phone number from Active Directory.

Definition at line 199 of file AcUsers.cs.

string AcUtils.AcUser.Description
get

User's description from Active Directory.

Definition at line 215 of file AcUsers.cs.

string AcUtils.AcUser.DisplayName
get

User's display name from Active Directory, e.g. Doe, John

Definition at line 191 of file AcUsers.cs.

Referenced by AcUtils.AcUser.CompareTo().

string AcUtils.AcUser.DistinguishedName
get

User's distinguished name from Active Directory.

Definition at line 223 of file AcUsers.cs.

string AcUtils.AcUser.EmailAddress
get

User's email address from Active Directory.

Definition at line 207 of file AcUsers.cs.

string AcUtils.AcUser.GivenName
get

User's given name from Active Directory, e.g. John

Definition at line 167 of file AcUsers.cs.

string AcUtils.AcUser.MiddleName
get

User's middle name from Active Directory.

Definition at line 175 of file AcUsers.cs.

IDictionary<string, object> AcUtils.AcUser.Other
get

Additional Active Directory user properties not in the regular default set.

Optionally initialized during list construction for user properties beyond the default set. Elements are [title,value] pairs: title from the properties section in <prog_name>.exe.config and its value from Active Directory.

<activeDir>
<!-- contact your company LDAP administrator for these values -->
<domains>
<add host="xyzdc.mycorp.com" path="DC=XYZ,DC=xy,DC=zcorp,DC=com"/>
<add host="abcdc.mycorp.com" path="DC=ABC,DC=ab,DC=com"/>
</domains>
<properties>
<add field="mobile" title="Mobile"/>
<add field="manager" title="Manager"/>
<add field="department" title="Department"/>
</properties>
</activeDir>
...
row["GivenName"] = user.GivenName;
row["Surname"] = user.Surname;
row["Mobile"] = user.Other.ContainsKey("Mobile") ? user.Other["Mobile"] : String.Empty;
row["EmailAddress"] = user.EmailAddress;
row["Manager"] = user.Other.ContainsKey("Manager") ? getManager((string)user.Other["Manager"]) : String.Empty;
row["Department"] = user.Other.ContainsKey("Department") ? user.Other["Department"] : String.Empty;
row["Description"] = user.Description;
...
See also
PropCollection

Definition at line 263 of file AcUsers.cs.

AcPrincipal AcUtils.AcUser.Principal
get

AccuRev principal attributes name, ID, and status (active or inactive), and optionally their group membership list as per AcUsers constructor includeGroupsList parameter.

Definition at line 157 of file AcUsers.cs.

Referenced by AcUtils.AcDepots.canViewAsync(), AcUtils.AcUser.CompareTo(), AcUtils.AcUser.getGroups(), AcUtils.AcUser.GetHashCode(), AcUtils.AcUser.initFromADAsync(), and AcUtils.AcUser.initGroupsListAsync().

string AcUtils.AcUser.Surname
get

User's surname from Active Directory, e.g. Doe

Definition at line 183 of file AcUsers.cs.