From 29c8cc70a236feb672f9c94b8abeb820d705d754 Mon Sep 17 00:00:00 2001 From: David Hall Date: Sat, 10 Aug 2019 14:11:50 -0600 Subject: [PATCH] Cleaned up comments and enum types --- PInvoke/Security/AdvApi32/NTSecApi.cs | 120 +++++++++++++++++++--------------- 1 file changed, 69 insertions(+), 51 deletions(-) diff --git a/PInvoke/Security/AdvApi32/NTSecApi.cs b/PInvoke/Security/AdvApi32/NTSecApi.cs index abdf4995..a229d422 100644 --- a/PInvoke/Security/AdvApi32/NTSecApi.cs +++ b/PInvoke/Security/AdvApi32/NTSecApi.cs @@ -8,6 +8,46 @@ namespace Vanara.PInvoke /// Functions, enumerations and structures found in ADVAPI32.DLL. public static partial class AdvApi32 { + /// Flags that describe the password properties. + [PInvokeData("ntsecapi.h", MSDNShortId = "7dceaf70-d8de-47c0-b940-f0d6a0cca101")] + [Flags] + public enum DOMAIN_PASSWORD : uint + { + /// + /// The password must have a mix of at least two of the following types of characters: + /// + /// Uppercase characters + /// Lowercase characters + /// Numerals + /// + /// + DOMAIN_PASSWORD_COMPLEX = 0x00000001, + + /// + /// The password cannot be changed without logging on. Otherwise, if your password has expired, you can change your password and + /// then log on. + /// + DOMAIN_PASSWORD_NO_ANON_CHANGE = 0x00000002, + + /// Forces the client to use a protocol that does not allow the domain controller to get the plaintext password. + DOMAIN_PASSWORD_NO_CLEAR_CHANGE = 0x00000004, + + /// Allows the built-in administrator account to be locked out from network logons. + DOMAIN_LOCKOUT_ADMINS = 0x00000008, + + /// The directory service is storing a plaintext password for all users instead of a hash function of the password. + DOMAIN_PASSWORD_STORE_CLEARTEXT = 0x00000010, + + /// + /// Removes the requirement that the machine account password be automatically changed every week. + /// This value should not be used as it can weaken security. + /// + DOMAIN_REFUSE_PASSWORD_CHANGE = 0x00000020, + + /// + DOMAIN_NO_LM_OWF_CHANGE = 0x00000040 + } + /// The POLICY_DOMAIN_INFORMATION_CLASS enumeration defines the type of policy domain information. // https://docs.microsoft.com/en-us/windows/desktop/api/ntsecapi/ne-ntsecapi-_policy_domain_information_class typedef enum // _POLICY_DOMAIN_INFORMATION_CLASS { PolicyDomainQualityOfServiceInformation, PolicyDomainEfsInformation, @@ -153,6 +193,27 @@ namespace Vanara.PInvoke PolicyServerDisabled, } + /// + /// Specifies one of the following values to indicate the type of authentication information in the AuthInfo buffer. + /// + public enum TRUST_AUTH_TYPE + { + /// The format is unknown and will be ignored. + TRUST_AUTH_TYPE_NONE = 0, + + /// + /// The Windows NT 4.0 one-way format (OWF) of a plaintext password. Note that you cannot derive the clear password back from the + /// OWF form of the password. The system sets this information. + /// + TRUST_AUTH_TYPE_NT4OWF = 1, + + /// Plaintext password to use for the trust. + TRUST_AUTH_TYPE_CLEAR = 2, + + /// Plaintext password version number. + TRUST_AUTH_TYPE_VERSION = 3, + } + /// Indicates the attributes of a trust relationship. [PInvokeData("ntsecapi.h", MSDNShortId = "acf9a2b5-f301-4e6a-a515-df338658ad56")] [Flags] @@ -295,10 +356,11 @@ namespace Vanara.PInvoke /// /// It is used in the MSV1_0_CHANGEPASSWORD_RESPONSE structure. /// - // https://docs.microsoft.com/en-us/windows/desktop/api/ntsecapi/ns-ntsecapi-_domain_password_information typedef struct + // https://docs.microsoft.com/en-us/windows/win32/api/ntsecapi/ns-ntsecapi-domain_password_information typedef struct // _DOMAIN_PASSWORD_INFORMATION { USHORT MinPasswordLength; USHORT PasswordHistoryLength; ULONG PasswordProperties; #if ... - // OLD_LARGE_INTEGER MaxPasswordAge; #if ... OLD_LARGE_INTEGER MinPasswordAge; #else LARGE_INTEGER MaxPasswordAge; #endif #else - // LARGE_INTEGER MinPasswordAge; #endif } DOMAIN_PASSWORD_INFORMATION, *PDOMAIN_PASSWORD_INFORMATION; + // OLD_LARGE_INTEGER MaxPasswordAge; #elif OLD_LARGE_INTEGER MaxPasswordAge; #if ... OLD_LARGE_INTEGER MinPasswordAge; #elif + // OLD_LARGE_INTEGER MinPasswordAge; #elif LARGE_INTEGER MaxPasswordAge; #else LARGE_INTEGER MaxPasswordAge; #endif #elif + // LARGE_INTEGER MinPasswordAge; #else LARGE_INTEGER MinPasswordAge; #endif } DOMAIN_PASSWORD_INFORMATION, *PDOMAIN_PASSWORD_INFORMATION; [PInvokeData("ntsecapi.h", MSDNShortId = "7dceaf70-d8de-47c0-b940-f0d6a0cca101")] [StructLayout(LayoutKind.Sequential)] public struct DOMAIN_PASSWORD_INFORMATION @@ -356,13 +418,13 @@ namespace Vanara.PInvoke /// A 64-bit value, with delta time syntax, indicating the policy setting for the maximum time allowed before a password reset or /// change is required. /// - public long MaxPasswordAge; + public FILETIME MaxPasswordAge; /// /// A 64-bit value, with delta time syntax, indicating the policy setting for the minimum time allowed before a password change /// operation is allowed. /// - public long MinPasswordAge; + public FILETIME MinPasswordAge; } /// @@ -376,12 +438,10 @@ namespace Vanara.PInvoke public struct LSA_AUTH_INFORMATION { /// - /// /// A LARGE_INTEGER structure that uses the Coordinated Universal Time (Greenwich Mean Time) format to indicate the time that /// this value was set. For more information about Coordinated Universal Time, see the FILETIME structure. - /// /// - public long LastUpdateTime; + public FILETIME LastUpdateTime; /// /// Specifies one of the following values to indicate the type of authentication information in the AuthInfo buffer. @@ -411,7 +471,7 @@ namespace Vanara.PInvoke /// /// /// - public uint AuthType; + public TRUST_AUTH_TYPE AuthType; /// /// Specifies the size, in bytes, of the AuthInfo member. @@ -419,9 +479,7 @@ namespace Vanara.PInvoke public uint AuthInfoLength; /// - /// /// Pointer to an array of bytes that contains the type of authentication information indicated by the AuthType member. - /// /// public IntPtr AuthInfo; } @@ -658,10 +716,8 @@ namespace Vanara.PInvoke } /// - /// /// The TRUSTED_DOMAIN_AUTH_INFORMATION structure is used to retrieve authentication information for a trusted domain. The /// LsaQueryTrustedDomainInfo function uses this structure when its InformationClass parameter is set to TrustedDomainAuthInformation. - /// /// // https://docs.microsoft.com/en-us/windows/desktop/api/ntsecapi/ns-ntsecapi-_trusted_domain_auth_information typedef struct // _TRUSTED_DOMAIN_AUTH_INFORMATION { ULONG IncomingAuthInfos; PLSA_AUTH_INFORMATION IncomingAuthenticationInformation; @@ -673,61 +729,47 @@ namespace Vanara.PInvoke public struct TRUSTED_DOMAIN_AUTH_INFORMATION { /// - /// /// Specifies the number of entries in the IncomingAuthenticationInformation and /// IncomingPreviousAuthenticationInformation arrays. - /// /// public uint IncomingAuthInfos; /// - /// /// Pointer to an array of LSA_AUTH_INFORMATION structures containing the authentication information for the incoming side of a /// trust relationship. - /// /// public IntPtr IncomingAuthenticationInformation; /// - /// /// Pointer to an array of LSA_AUTH_INFORMATION structures containing the previous authentication information (or old password) /// for the incoming side of a trust relationship. There must be one of these for every entry in the /// IncomingAuthenticationInformation array. - /// /// public IntPtr IncomingPreviousAuthenticationInformation; /// - /// /// Specifies the number of entries in the OutgoingAuthenticationInformation and /// OutgoingPreviousAuthenticationInformation arrays. - /// /// public uint OutgoingAuthInfos; /// - /// /// Pointer to an array of LSA_AUTH_INFORMATION structures containing the authentication information for the outgoing side of a /// trust relationship. - /// /// public IntPtr OutgoingAuthenticationInformation; /// - /// /// Pointer to an array of LSA_AUTH_INFORMATION structures containing the previous authentication information (or old password) /// for the outgoing side of a trust relationship. There must be one of these for every entry in the /// OutgoingAuthenticationInformation array. - /// /// public IntPtr OutgoingPreviousAuthenticationInformation; } /// - /// /// The TRUSTED_DOMAIN_FULL_INFORMATION structure is used to retrieve complete information about a trusted domain. The /// LsaQueryTrustedDomainInfo function uses this structure when its InformationClass parameter is set to TrustedDomainFullInformation. - /// /// // https://docs.microsoft.com/en-us/windows/desktop/api/ntsecapi/ns-ntsecapi-_trusted_domain_full_information typedef struct // _TRUSTED_DOMAIN_FULL_INFORMATION { TRUSTED_DOMAIN_INFORMATION_EX Information; TRUSTED_POSIX_OFFSET_INFO PosixOffset; @@ -742,9 +784,7 @@ namespace Vanara.PInvoke public TRUSTED_DOMAIN_INFORMATION_EX Information; /// - /// /// A TRUSTED_POSIX_OFFSET_INFO structure containing the value used to generate Posix user and group identifiers for a trusted domain. - /// /// public TRUSTED_POSIX_OFFSET_INFO PosixOffset; @@ -755,10 +795,8 @@ namespace Vanara.PInvoke } /// - /// /// The TRUSTED_DOMAIN_INFORMATION_EX structure is used to retrieve extended information about a trusted domain. The /// LsaQueryTrustedDomainInfo function uses this structure when its InformationClass parameter is set to TrustedDomainInformationEx. - /// /// // https://docs.microsoft.com/en-us/windows/desktop/api/ntsecapi/ns-ntsecapi-_trusted_domain_information_ex typedef struct // _TRUSTED_DOMAIN_INFORMATION_EX { LSA_UNICODE_STRING Name; LSA_UNICODE_STRING FlatName; PSID Sid; ULONG TrustDirection; ULONG @@ -768,25 +806,19 @@ namespace Vanara.PInvoke public struct TRUSTED_DOMAIN_INFORMATION_EX { /// - /// /// An LSA_UNICODE_STRING structure that contains the name of the trusted domain. This is the DNS domain name. For non-Microsoft /// trusted domains, this is the identifying name of the domain. - /// /// public LSA_UNICODE_STRING Name; /// - /// /// An LSA_UNICODE_STRING structure that contains the flat name of the trusted domain. For non-Microsoft trusted domains, this is /// the identifying name of the domain or it is NULL. - /// /// public LSA_UNICODE_STRING FlatName; /// - /// /// Pointer to the security identifier (SID) of the trusted domain. For non-Microsoft trusted domains, this member can be NULL. - /// /// public PSID Sid; @@ -893,10 +925,8 @@ namespace Vanara.PInvoke } /// - /// /// The TRUSTED_DOMAIN_NAME_INFO structure is used to query or set the name of a trusted domain. The LsaQueryTrustedDomainInfo /// and LsaSetTrustedDomainInformation functions use this structure when their InformationClass parameters are set to TrustedDomainNameInformation. - /// /// // https://docs.microsoft.com/en-us/windows/desktop/api/ntsecapi/ns-ntsecapi-_trusted_domain_name_info typedef struct // _TRUSTED_DOMAIN_NAME_INFO { LSA_UNICODE_STRING Name; } TRUSTED_DOMAIN_NAME_INFO, *PTRUSTED_DOMAIN_NAME_INFO; @@ -911,17 +941,13 @@ namespace Vanara.PInvoke } /// - /// /// The TRUSTED_PASSWORD_INFO structure is used to query or set the password for a trusted domain. The /// LsaQueryTrustedDomainInfo and LsaSetTrustedDomainInformation functions use this structure when their InformationClass parameters /// are set to TrustedPasswordInformation. - /// /// /// - /// /// When you have finished using the TRUSTED_PASSWORD_INFO structure, clear the sensitive information from memory by calling /// the SecureZeroMemory function. For more information about protecting passwords, see Handling Passwords. - /// /// // https://docs.microsoft.com/en-us/windows/desktop/api/ntsecapi/ns-ntsecapi-_trusted_password_info typedef struct // _TRUSTED_PASSWORD_INFO { LSA_UNICODE_STRING Password; LSA_UNICODE_STRING OldPassword; } TRUSTED_PASSWORD_INFO, *PTRUSTED_PASSWORD_INFO; @@ -930,27 +956,21 @@ namespace Vanara.PInvoke public struct TRUSTED_PASSWORD_INFO { /// - /// /// An LSA_UNICODE_STRING structure that contains the password to use when creating an authenticated connection to the domain. - /// /// public LSA_UNICODE_STRING Password; /// - /// /// An LSA_UNICODE_STRING structure that contains the old password. On set operations, if the Buffer member of this /// structure is NULL, the old password is set to the current password. - /// /// public LSA_UNICODE_STRING OldPassword; } /// - /// /// The TRUSTED_POSIX_OFFSET_INFO structure is used to query or set the value used to generate Posix user and group /// identifiers. The LsaQueryTrustedDomainInfo and LsaSetTrustedDomainInformation functions use this structure when their /// InformationClass parameters are set to TrustedPosixOffsetInformation. - /// /// // https://docs.microsoft.com/en-us/windows/desktop/api/ntsecapi/ns-ntsecapi-_trusted_posix_offset_info typedef struct // _TRUSTED_POSIX_OFFSET_INFO { ULONG Offset; } TRUSTED_POSIX_OFFSET_INFO, *PTRUSTED_POSIX_OFFSET_INFO; @@ -959,10 +979,8 @@ namespace Vanara.PInvoke public struct TRUSTED_POSIX_OFFSET_INFO { /// - /// /// An offset that the system uses to generate Posix user and group identifiers that correspond to a given SID. To generate a /// Posix identifier, the system adds the RID from the SID to the Posix offset of the trusted domain identified by the SID. - /// /// public uint Offset; }