1 // Licensed to the .NET Foundation under one or more agreements. 2 // The .NET Foundation licenses this file to you under the MIT license. 3 // See the LICENSE file in the project root for more information. 4 5 using System; 6 using System.Collections; 7 8 namespace System.DirectoryServices.AccountManagement 9 { 10 // This enum tracks the load state of our principal side data cache. 11 // NotSet = default value, 12 // Loaded = Value from store was set into cache date, Data in cache matches data in store. 13 // Changed = User has modifed the cache value but is has not been pushed to the store yet 14 internal enum LoadState 15 { 16 NotSet = 0, 17 Loaded, 18 Changed 19 } 20 21 // These are the default options used when a user does not specify a context option to connect to the store. 22 internal static class DefaultContextOptions 23 { 24 internal static ContextOptions MachineDefaultContextOption = ContextOptions.Negotiate; 25 internal static ContextOptions ADDefaultContextOption = ContextOptions.Negotiate | ContextOptions.Signing | ContextOptions.Sealing; 26 } 27 28 internal class LdapConstants 29 { 30 public static int LDAP_SSL_PORT = 636; 31 public static int LDAP_PORT = 389; 32 internal static DateTime defaultUtcTime = new DateTime(1601, 1, 1, 0, 0, 0); LdapConstants()33 private LdapConstants() { } 34 } 35 // The string constants used internally to specify each property 36 internal class PropertyNames 37 { PropertyNames()38 private PropertyNames() { } 39 // Principal 40 internal const string PrincipalDisplayName = "Principal.DisplayName"; 41 internal const string PrincipalDescription = "Principal.Description"; 42 internal const string PrincipalSamAccountName = "Principal.SamAccountName"; 43 internal const string PrincipalUserPrincipalName = "Principal.UserPrincipalName"; 44 internal const string PrincipalGuid = "Principal.Guid"; 45 internal const string PrincipalSid = "Principal.Sid"; 46 internal const string PrincipalIdentityClaims = "Principal.IdentityClaims"; 47 internal const string PrincipalDistinguishedName = "Principal.DistinguishedName"; 48 internal const string PrincipalStructuralObjectClass = "Principal.StructuralObjectClass"; 49 internal const string PrincipalName = "Principal.Name"; 50 internal const string PrincipalExtensionCache = "Principal.ExtensionCache"; 51 52 // AuthenticablePrincipal 53 internal const string AuthenticablePrincipalEnabled = "AuthenticablePrincipal.Enabled"; 54 internal const string AuthenticablePrincipalCertificates = "AuthenticablePrincipal.Certificates"; 55 56 // Group 57 internal const string GroupIsSecurityGroup = "GroupPrincipal.IsSecurityGroup"; 58 internal const string GroupGroupScope = "GroupPrincipal.GroupScope"; 59 internal const string GroupMembers = "GroupPrincipal.Members"; 60 61 // User 62 internal const string UserGivenName = "UserPrincipal.GivenName"; 63 internal const string UserMiddleName = "UserPrincipal.MiddleName"; 64 internal const string UserSurname = "UserPrincipal.Surname"; 65 internal const string UserEmailAddress = "UserPrincipal.EmailAddress"; 66 internal const string UserVoiceTelephoneNumber = "UserPrincipal.VoiceTelephoneNumber"; 67 internal const string UserEmployeeID = "UserPrincipal.EmployeeId"; 68 69 // Computer 70 internal const string ComputerServicePrincipalNames = "ComputerPrincipal.ServicePrincipalNames"; 71 72 // AccountInfo 73 internal const string AcctInfoPrefix = "AuthenticablePrincipal.AccountInfo"; 74 internal const string AcctInfoAcctLockoutTime = "AuthenticablePrincipal.AccountInfo.AccountLockoutTime"; 75 internal const string AcctInfoLastLogon = "AuthenticablePrincipal.AccountInfo.LastLogon"; 76 internal const string AcctInfoPermittedWorkstations = "AuthenticablePrincipal.AccountInfo.PermittedWorkstations"; 77 internal const string AcctInfoPermittedLogonTimes = "AuthenticablePrincipal.AccountInfo.PermittedLogonTimes"; 78 internal const string AcctInfoExpirationDate = "AuthenticablePrincipal.AccountInfo.AccountExpirationDate"; 79 internal const string AcctInfoSmartcardRequired = "AuthenticablePrincipal.AccountInfo.SmartcardLogonRequired"; 80 internal const string AcctInfoDelegationPermitted = "AuthenticablePrincipal.AccountInfo.DelegationPermitted"; 81 internal const string AcctInfoBadLogonCount = "AuthenticablePrincipal.AccountInfo.BadLogonCount"; 82 internal const string AcctInfoHomeDirectory = "AuthenticablePrincipal.AccountInfo.HomeDirectory"; 83 internal const string AcctInfoHomeDrive = "AuthenticablePrincipal.AccountInfo.HomeDrive"; 84 internal const string AcctInfoScriptPath = "AuthenticablePrincipal.AccountInfo.ScriptPath"; 85 // This property is not publicly exposed but is used be a ReadOnlySearchFilter. 86 internal const string AcctInfoExpiredAccount = "AuthenticablePrincipal.AccountInfoExpired"; 87 88 // PasswordInfo 89 internal const string PwdInfoPrefix = "AuthenticablePrincipal.PasswordInfo"; 90 internal const string PwdInfoLastPasswordSet = "AuthenticablePrincipal.PasswordInfo.LastPasswordSet"; 91 internal const string PwdInfoLastBadPasswordAttempt = "AuthenticablePrincipal.PasswordInfo.LastBadPasswordAttempt"; 92 internal const string PwdInfoPasswordNotRequired = "AuthenticablePrincipal.PasswordInfo.PasswordNotRequired"; 93 internal const string PwdInfoPasswordNeverExpires = "AuthenticablePrincipal.PasswordInfo.PasswordNeverExpires"; 94 internal const string PwdInfoCannotChangePassword = "AuthenticablePrincipal.PasswordInfo.UserCannotChangePassword"; 95 internal const string PwdInfoAllowReversiblePasswordEncryption = "AuthenticablePrincipal.PasswordInfo.AllowReversiblePasswordEncryption"; 96 97 // these two are not publicly exposed properties, but are used internally to track ResetPassword/ExpirePasswordNow 98 // operations against unpersisted principals, so that they can be performed once the principal has been Saved 99 internal const string PwdInfoPassword = "AuthenticablePrincipal.PasswordInfo.Password"; 100 internal const string PwdInfoExpireImmediately = "AuthenticablePrincipal.PasswordInfo.ExpireImmediately"; 101 } 102 103 // Given an internal property name (from PropertyNames), returns the external form of the name for use in error-reporting 104 internal class PropertyNamesExternal 105 { PropertyNamesExternal()106 private PropertyNamesExternal() { } 107 108 private static int s_acctInfoPrefixLength = PropertyNames.AcctInfoPrefix.Length; 109 private static int s_pwdInfoPrefixLength = PropertyNames.PwdInfoPrefix.Length; 110 GetExternalForm(string propertyName)111 internal static string GetExternalForm(string propertyName) 112 { 113 if (propertyName.StartsWith(PropertyNames.AcctInfoPrefix, StringComparison.Ordinal)) 114 { 115 return "AuthenticablePrincipal" + propertyName.Substring(s_acctInfoPrefixLength); 116 } 117 else if (propertyName.StartsWith(PropertyNames.PwdInfoPrefix, StringComparison.Ordinal)) 118 { 119 return "AuthenticablePrincipal" + propertyName.Substring(s_pwdInfoPrefixLength); 120 } 121 else 122 { 123 return propertyName; 124 } 125 } 126 } 127 128 // The list of properties considered referential (they refer to or contain Principal objects) 129 // 130 // At present, referential properties are the following: 131 // 132 // Group.Members 133 // 134 internal class ReferentialProperties 135 { ReferentialProperties()136 private ReferentialProperties() { } 137 138 // Maps from Type of the Principal object --> ArrayList of the object's referential property names 139 // (expressed as strings from the PropertyNames class) 140 internal static readonly Hashtable Properties; 141 ReferentialProperties()142 static ReferentialProperties() 143 { 144 Properties = new Hashtable(); 145 146 // Referential properties for groups 147 ArrayList groupList = new ArrayList(1); 148 groupList.Add(PropertyNames.GroupMembers); 149 150 Properties[typeof(GroupPrincipal)] = groupList; 151 152 // Referential properties for users 153 // None at this time. 154 155 // Referential properties for computers 156 // None at this time. 157 } 158 } 159 } 160