diff --git a/SnaffCore/ADObject.cs b/SnaffCore/ADObject.cs new file mode 100644 index 00000000..328e9bd0 --- /dev/null +++ b/SnaffCore/ADObject.cs @@ -0,0 +1,76 @@ +using DSInternals.Common.Data; +using System; +using System.Collections.Generic; +using System.DirectoryServices; +using System.Globalization; +using System.Linq; +using System.Net.NetworkInformation; +using System.Security.Cryptography.X509Certificates; +using System.Security.Principal; +using System.Text; +using System.Threading.Tasks; + +namespace SnaffCore.ADWS +{ + public class ADObject + { + public string Class { get; set; } + public int AdminCount { get; set; } + public X509Certificate2Collection CACertificate { get; set; } + public string[] CertificateTemplates { get; set; } + public string Description { get; set; } + public string DisplayName { get; set; } + public string DistinguishedName { get; set; } + public string DNSHostName { get; set; } + public string Cn { get; set; } + public byte[] DnsRecord { get; set; } + public int DSMachineAccountQuota { get; set; } + public string GPCFileSysPath { get; set; } + public string IsDeleted { get; set; } + public string GPLink { get; set; } + public int GPOptions { get; set; } + public DateTime LastLogon { get; set; } + public DateTime LastLogonTimestamp { get; set; } + public string[] Member { get; set; } + public ActiveDirectorySecurity MsDSAllowedToActOnBehalfOfOtherIdentity { get; set; } + public KeyCredential[] MsDSKeyCredentialLink { get; set; } + public string[] MsDSAllowedToDelegateTo { get; set; } + public int FunctionalLevel { get; set; } + public long MsMCSAdmPwdExpirationTime { get; set; } + public int MsPKICertificateNameFlag { get; set; } + public int MsPKIMinimalKeySize { get; set; } + public int MsPKIEnrollmentFlag { get; set; } + public int MsPKIPrivateKeyFlag { get; set; } + public string Name { get; set; } + public ActiveDirectorySecurity NTSecurityDescriptor { get; set; } + public Guid ObjectGUID { get; set; } + public SecurityIdentifier ObjectSid { get; set; } + public string OperatingSystem { get; set; } + public string[] PKIExtendedKeyUsage { get; set; } + public int PrimaryGroupID { get; set; } + public DateTime PwdLastSet { get; set; } + public string SAMAccountName { get; set; } + public string ScriptPath { get; set; } + public SecurityIdentifier SecurityIdentifier { get; set; } + public string[] ServicePrincipalName { get; set; } + public SecurityIdentifier[] SIDHistory { get; set; } + public int TrustAttributes { get; set; } + public int TrustDirection { get; set; } + public int UserAccountControl { get; set; } + public DateTime WhenCreated { get; set; } + public string Email { get; set; } + public string Title { get; set; } + public string HomeDirectory { get; set; } + public string UserPassword { get; set; } + public string UnixUserPassword { get; set; } + public string UnicodePassword { get; set; } + public string MsSFU30Password { get; set; } + public byte[] PKIExpirationPeriod { get; set; } + public byte[] PKIOverlapPeriod { get; set; } + public ADObject() + { + } + } + + +} diff --git a/SnaffCore/ADWS/ADWSConnection.cs b/SnaffCore/ADWS/ADWSConnection.cs new file mode 100644 index 00000000..873d2c03 --- /dev/null +++ b/SnaffCore/ADWS/ADWSConnection.cs @@ -0,0 +1,70 @@ +using System.ServiceModel; +using System.ServiceModel.Channels; +using System.Xml.Serialization; +using System.Xml; +using System.Xml.Linq; +using System.ServiceModel.Description; +using System.Globalization; +using System.Security.Principal; +using System.DirectoryServices; +using System; +using System.Linq; +using System.Collections.Generic; +using System.IO; +using System.Threading.Tasks; +using System.Net; +using System.Security.Cryptography.X509Certificates; +using System.Text.RegularExpressions; +using SnaffCore.ADWS; + +namespace SnaffCore.ADWS +{ + internal class ADWSConnection + { + public string BaseUri { get; set; } + public string Instance { get; set; } + public string DomainName { get; set; } + public string DefaultNamingContext { get; set; } + public NetworkCredential Credentials { get; set; } + + public NetTcpBinding Binding { get; set; } + public MessageVersion Version { get; set; } + public ADWSConnection(string domainName, string instance, NetworkCredential credentials) + { + this.DomainName = domainName; + UriBuilder uriBuilder = new UriBuilder(); + uriBuilder.Scheme = "net.tcp"; + uriBuilder.Host = domainName; + uriBuilder.Port = 9389; + this.BaseUri = uriBuilder.ToString(); + + this.Instance = instance; + + this.Binding = new NetTcpBinding(); + + this.Binding.OpenTimeout = new TimeSpan(0, 10, 0); + this.Binding.CloseTimeout = new TimeSpan(0, 10, 0); + this.Binding.SendTimeout = new TimeSpan(0, 10, 0); + this.Binding.ReceiveTimeout = new TimeSpan(0, 10, 0); + this.Binding.MaxBufferSize = 1073741824; + this.Binding.MaxReceivedMessageSize = 1073741824; + this.Binding.ReaderQuotas.MaxDepth = 64; + this.Binding.ReaderQuotas.MaxArrayLength = 2147483647; + this.Binding.ReaderQuotas.MaxStringContentLength = 2147483647; + this.Binding.ReaderQuotas.MaxNameTableCharCount = 2147483647; + this.Binding.ReaderQuotas.MaxBytesPerRead = 2147483647; + EnvelopeVersion envelopeVersion = EnvelopeVersion.Soap12; + AddressingVersion addressingVersion = AddressingVersion.WSAddressing10; + this.Version = MessageVersion.CreateVersion(envelopeVersion, addressingVersion); + this.Credentials = credentials; + + foreach (String DC in domainName.Split('.')) + { + this.DefaultNamingContext += ",DC=" + DC; + } + this.DefaultNamingContext = this.DefaultNamingContext.TrimStart(','); + } + + + } +} diff --git a/SnaffCore/ADWS/Enumeration/EnumerateRequest.cs b/SnaffCore/ADWS/Enumeration/EnumerateRequest.cs new file mode 100644 index 00000000..eaee078e --- /dev/null +++ b/SnaffCore/ADWS/Enumeration/EnumerateRequest.cs @@ -0,0 +1,79 @@ +using Microsoft.ActiveDirectory.Management.IMDA; +using System; +using System.Collections.Generic; +using System.DirectoryServices.Protocols; +using System.Linq; +using System.Net; +using System.ServiceModel.Channels; +using System.ServiceModel.Description; +using System.ServiceModel; +using System.Text; +using System.Threading.Tasks; +using Microsoft.ActiveDirectory.Management.WSE; +using System.Xml.Linq; +using System.Text.RegularExpressions; + +namespace SnaffCore.ADWS.Enumeration +{ + internal class EnumerateRequest + { + ADWSConnection adwsConnection = null; + string Instance { get; set; } + string BaseUri { get; set; } + NetworkCredential Credentials { get; set; } + + NetTcpBinding Binding { get; set; } + MessageVersion Version { get; set; } + + public EnumerateRequest(ADWSConnection adwsConnection) + { + this.adwsConnection = adwsConnection; + this.Instance = adwsConnection.Instance; + this.BaseUri = adwsConnection.BaseUri; + this.Binding = adwsConnection.Binding; + this.Credentials = adwsConnection.Credentials; + } + + public List Enumerate(string filter, string searchBase, string searchScope, IList attributeList) + { + var endpointAddress = new System.ServiceModel.EndpointAddress(this.BaseUri + "ActiveDirectoryWebServices/Windows/Enumeration"); + var searchClient = new Microsoft.ActiveDirectory.WebServices.Proxy.SearchClient(this.Binding, endpointAddress); + UpdateCredentials(searchClient.ClientCredentials); + + DirectoryControl[] controls = new DirectoryControl[2]; + controls[0] = new PageResultRequestControl(); + controls[1] = new SecurityDescriptorFlagControl(System.DirectoryServices.Protocols.SecurityMasks.Dacl); + + ADEnumerateLdapRequest Request = new ADEnumerateLdapRequest(this.Instance, filter, searchBase, searchScope, attributeList); + + Message resp = searchClient.Enumerate(Request); + + var enumerateResponse = MessageToXDocument(resp); + string enumerationContext = enumerateResponse + .Descendants(XName.Get("EnumerationContext", "http://schemas.xmlsoap.org/ws/2004/09/enumeration")) + .FirstOrDefault()? + .Value; + + PullRequest pullRequest = new PullRequest(adwsConnection); + return pullRequest.Pull(searchClient, enumerationContext); + + } + + public void UpdateCredentials(ClientCredentials c) + { + c.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation; + c.Windows.ClientCredential = this.Credentials; + } + + static XDocument MessageToXDocument(Message message) + { + return XDocument.Parse(ReplaceHexadecimalSymbols(message.ToString())); + } + + static string ReplaceHexadecimalSymbols(string txt) + { + string r = "[\x00-\x08\x0B\x0C\x0E-\x1F\x26]"; + return Regex.Replace(txt, r, "", RegexOptions.Compiled); + } + } +} diff --git a/SnaffCore/ADWS/Enumeration/PullRequest.cs b/SnaffCore/ADWS/Enumeration/PullRequest.cs new file mode 100644 index 00000000..3271a09e --- /dev/null +++ b/SnaffCore/ADWS/Enumeration/PullRequest.cs @@ -0,0 +1,345 @@ +using Microsoft.ActiveDirectory.Management.WSE; +using System; +using System.Collections.Generic; +using System.DirectoryServices.Protocols; +using System.Linq; +using System.Net; +using System.ServiceModel.Channels; +using System.ServiceModel.Description; +using System.ServiceModel; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using System.Xml.Linq; +using SnaffCore.ADWS.Transfer; +using System.Globalization; +using System.Security.Principal; +using System.DirectoryServices; +using System.Security.Cryptography.X509Certificates; +using Microsoft.ActiveDirectory.WebServices.Proxy; +using DSInternals.Common.Data; + +namespace SnaffCore.ADWS.Enumeration +{ + internal class PullRequest + { + string Instance { get; set; } + string BaseUri { get; set; } + NetworkCredential Credentials { get; set; } + NetTcpBinding Binding { get; set; } + + public PullRequest(ADWSConnection adwsConnection) + { + this.Instance = adwsConnection.Instance; + this.BaseUri = adwsConnection.BaseUri; + this.Binding = adwsConnection.Binding; + this.Credentials = adwsConnection.Credentials; + } + + public List Pull(SearchClient searchClient, string enumerationContext, uint maxElements = 1000) + { + DirectoryControl[] controls = new DirectoryControl[1]; + controls[0] = new SecurityDescriptorFlagControl(System.DirectoryServices.Protocols.SecurityMasks.Dacl); + + var adObjects = new List(); + bool endOfSequence = false; + while (!endOfSequence) + { + ADPullRequest Request = new ADPullRequest(this.Instance, enumerationContext, controls); + Request.MaxElements = maxElements; + Message resp = searchClient.Pull(Request); + var pullResponse = MessageToXDocument(resp); + adObjects.AddRange(ExtractADObjectsFromResponse(pullResponse)); + endOfSequence = pullResponse + .Descendants(XName.Get("EndOfSequence", "http://schemas.xmlsoap.org/ws/2004/09/enumeration")) + .Count() > 0; + } + + return adObjects; + } + + public void UpdateCredentials(ClientCredentials c) + { + c.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation; + c.Windows.ClientCredential = this.Credentials; + } + + static XDocument MessageToXDocument(Message message) + { + return XDocument.Parse(ReplaceHexadecimalSymbols(message.ToString())); + } + + static string ReplaceHexadecimalSymbols(string txt) + { + string r = "[\x00-\x08\x0B\x0C\x0E-\x1F\x26]"; + return Regex.Replace(txt, r, "", RegexOptions.Compiled); + } + + private static List ExtractADObjectsFromResponse(XDocument pullResponse) + { + XNamespace addata = "http://schemas.microsoft.com/2008/1/ActiveDirectory/Data"; + XNamespace ad = "http://schemas.microsoft.com/2008/1/ActiveDirectory"; + XNamespace wsen = "http://schemas.xmlsoap.org/ws/2004/09/enumeration"; + + var entries = new List>(); + var arrayKeys = new List { "member", "msDS-AllowedToDelegateTo", "msDS-KeyCredentialLink", "pKIExtendedKeyUsage", "servicePrincipalName", "certificateTemplates", "cACertificate", "sIDHistory" }; + + var adObjects = new List { }; + + foreach (var element in pullResponse.Descendants(wsen + "Items").Elements()) + { + var adobject = new ADObject(); + adobject.Class = element.Name.LocalName.ToLowerInvariant(); + foreach (var property in element.Elements()) + { + var propertyName = property.Name.LocalName; + var propertyValue = property.Element(ad + "value").Value; + string[] propertyValues = null; + if (arrayKeys.Contains(propertyName)) + { + propertyValues = property.Elements(ad + "value").Select(v => v.Value).ToArray(); + } + switch (propertyName) + { + case "class": + adobject.Class = propertyValue; + break; + case "adminCount": + adobject.AdminCount = int.Parse(propertyValue); + break; + case "cACertificate": + adobject.CACertificate = ParseX509Certificate2Collection(propertyValues); + break; + case "certificateTemplates": + adobject.CertificateTemplates = propertyValues; + break; + case "description": + adobject.Description = propertyValue; + break; + case "displayName": + adobject.DisplayName = propertyValue; + break; + case "distinguishedName": + adobject.DistinguishedName = propertyValue; + break; + case "dNSHostName": + adobject.DNSHostName = propertyValue; + break; + case "cn": + adobject.Cn = propertyValue; + break; + case "dnsRecord": + adobject.DnsRecord = Convert.FromBase64String(propertyValue); + break; + case "ms-DS-MachineAccountQuota": + adobject.DSMachineAccountQuota = int.Parse(propertyValue); + break; + case "gPCFileSysPath": + adobject.GPCFileSysPath = propertyValue; + break; + case "isDeleted": + adobject.IsDeleted = propertyValue; + break; + case "gPLink": + adobject.GPLink = propertyValue; + break; + case "gPOptions": + adobject.GPOptions = int.Parse(propertyValue); + break; + case "lastLogon": + adobject.LastLogon = DateTime.FromFileTime(long.Parse(propertyValue)); + break; + case "lastLogonTimestamp": + adobject.LastLogonTimestamp = DateTime.FromFileTime(long.Parse(propertyValue)); + break; + case "member": + adobject.Member = propertyValues; + break; + case "msDS-AllowedToActOnBehalfOfOtherIdentity": + adobject.MsDSAllowedToActOnBehalfOfOtherIdentity = ParseActiveDirectorySecurity(propertyValue); + break; + case "msDS-AllowedToDelegateTo": + adobject.MsDSAllowedToDelegateTo = propertyValues; + break; + case "msDS-KeyCredentialLink": + adobject.MsDSKeyCredentialLink = ParseKeyCredential(propertyValues); + break; + case "msDS-Behavior-Version": + adobject.FunctionalLevel = int.Parse(propertyValue); + break; + case "ms-Mcs-AdmPwdExpirationTime": + adobject.MsMCSAdmPwdExpirationTime = long.Parse(propertyValue); + break; + case "msPKI-Certificate-Name-Flag": + adobject.MsPKICertificateNameFlag = int.Parse(propertyValue); + break; + case "msPKI-Minimal-Key-Size": + adobject.MsPKIMinimalKeySize = int.Parse(propertyValue); + break; + case "msPKI-Enrollment-Flag": + adobject.MsPKIEnrollmentFlag = int.Parse(propertyValue); + break; + case "msPKI-Private-Key-Flag": + adobject.MsPKIPrivateKeyFlag = int.Parse(propertyValue); + break; + case "name": + adobject.Name = propertyValue; + break; + case "nTSecurityDescriptor": + adobject.NTSecurityDescriptor = ParseActiveDirectorySecurity(propertyValue); + break; + case "objectGUID": + adobject.ObjectGUID = new Guid(Convert.FromBase64String(propertyValue)); + break; + case "objectSid": + adobject.ObjectSid = new SecurityIdentifier(Convert.FromBase64String(propertyValue), 0); + break; + case "operatingSystem": + adobject.OperatingSystem = propertyValue; + break; + case "pKIExtendedKeyUsage": + adobject.PKIExtendedKeyUsage = propertyValues; + break; + case "primaryGroupID": + adobject.PrimaryGroupID = int.Parse(propertyValue); + break; + case "pwdLastSet": + adobject.PwdLastSet = DateTime.FromFileTime(long.Parse(propertyValue)); + break; + case "sAMAccountName": + adobject.SAMAccountName = propertyValue; + break; + case "scriptPath": + adobject.ScriptPath = propertyValue; + break; + case "securityIdentifier": + adobject.SecurityIdentifier = new SecurityIdentifier(Convert.FromBase64String(propertyValue), 0); + break; + case "servicePrincipalName": + adobject.ServicePrincipalName = propertyValues; + break; + case "sIDHistory": + adobject.SIDHistory = ParseSecurityIdentifierList(propertyValues); + break; + case "trustAttributes": + adobject.TrustAttributes = int.Parse(propertyValue); + break; + case "trustDirection": + adobject.TrustDirection = int.Parse(propertyValue); + break; + case "userAccountControl": + adobject.UserAccountControl = int.Parse(propertyValue); + break; + case "whenCreated": + adobject.WhenCreated = DateTime.ParseExact(propertyValue, "yyyyMMddHHmmss.f'Z'", CultureInfo.InvariantCulture); + break; + case "mail": + adobject.Email = propertyValue; + break; + case "title": + adobject.Title = propertyValue; + break; + case "homeDirectory": + adobject.HomeDirectory = propertyValue; + break; + case "userPassword": + adobject.UserPassword = propertyValue; + break; + case "unixUserPassword": + adobject.UnixUserPassword = propertyValue; + break; + case "unicodePassword": + adobject.UnicodePassword = propertyValue; + break; + case "msSFU30Password": + adobject.MsSFU30Password = propertyValue; + break; + case "pKIExpirationPeriod": + adobject.PKIExpirationPeriod = Convert.FromBase64String(propertyValue); + break; + case "pKIOverlapPeriod": + adobject.PKIOverlapPeriod = Convert.FromBase64String(propertyValue); + break; + default: + break; + } + } + adObjects.Add(adobject); + } + return adObjects; + } + + private static SecurityIdentifier[] ParseSecurityIdentifierList(string[] propertyValues) + { + List collection = new List(); + if (propertyValues == null) + { + return collection.ToArray(); + } + foreach (var propertyValue in propertyValues) + { + try + { + byte[] data = Convert.FromBase64String(propertyValue); + collection.Add(new SecurityIdentifier(data, 0)); + } + catch (Exception) + { + + } + } + return collection.ToArray(); + } + + private static ActiveDirectorySecurity ParseActiveDirectorySecurity(string value) + { + byte[] data = Convert.FromBase64String(value); + ActiveDirectorySecurity sd = new ActiveDirectorySecurity(); + sd.SetSecurityDescriptorBinaryForm(data); + return sd; + } + + private static X509Certificate2Collection ParseX509Certificate2Collection(string[] propertyValues) + { + X509Certificate2Collection collection = new X509Certificate2Collection(); + if (propertyValues == null) + { + return collection; + } + foreach (var propertyValue in propertyValues) + { + try + { + byte[] data = Convert.FromBase64String(propertyValue); + collection.Add(new X509Certificate2(data)); + } + catch (Exception) + { + + } + } + return collection; + } + + private static KeyCredential[] ParseKeyCredential(string[] propertyValues) + { + KeyCredential[] keyCredentialList = new KeyCredential[propertyValues.Length]; + if (propertyValues == null) + { + return keyCredentialList; + } + for (var i = 0; i < propertyValues.Length; i++) + { + try + { + keyCredentialList[i] = KeyCredential.ParseDNBinary(propertyValues[i]); + } + catch (Exception) + { + + } + } + return keyCredentialList; + } + } +} diff --git a/SnaffCore/ADWS/Transfer/CreateRequest.cs b/SnaffCore/ADWS/Transfer/CreateRequest.cs new file mode 100644 index 00000000..03cea84d --- /dev/null +++ b/SnaffCore/ADWS/Transfer/CreateRequest.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.ServiceModel.Channels; +using System.ServiceModel; +using System.Text; +using System.Threading.Tasks; +using Microsoft.ActiveDirectory.Management.IMDA; +using System.DirectoryServices.Protocols; +using System.ServiceModel.Description; +using System.Text.RegularExpressions; +using System.Xml.Linq; + +namespace SnaffCore.ADWS.Transfer +{ + internal class CreateRequest + { + string Instance { get; set; } + string BaseUri { get; set; } + NetworkCredential Credentials { get; set; } + + NetTcpBinding Binding { get; set; } + MessageVersion Version { get; set; } + + public CreateRequest(ADWSConnection adwsConnection) + { + this.Instance = adwsConnection.Instance; + this.BaseUri = adwsConnection.BaseUri; + this.Binding = adwsConnection.Binding; + this.Credentials = adwsConnection.Credentials; + } + + public Message AddRequest(string parent, string relativeDistinguishedName, IList directoryAttribute) + { + var endpointAddress = new System.ServiceModel.EndpointAddress(this.BaseUri + "ActiveDirectoryWebServices/Windows/ResourceFactory"); + var resourceFactoryClient = new Microsoft.ActiveDirectory.WebServices.Proxy.ResourceFactoryClient(this.Binding, endpointAddress); + UpdateCredentials(resourceFactoryClient.ClientCredentials); + + DirectoryControl[] controls = new DirectoryControl[1]; + controls[0] = new SecurityDescriptorFlagControl(); + + ADCreateRequestMsg Request = new ADCreateRequestMsg(this.Instance, parent, relativeDistinguishedName, controls, directoryAttribute); + + Message addResponse = resourceFactoryClient.Create(Request); + return addResponse; + } + + public void UpdateCredentials(ClientCredentials c) + { + c.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation; + c.Windows.ClientCredential = this.Credentials; + } + } +} diff --git a/SnaffCore/ADWS/Transfer/DeleteRequest.cs b/SnaffCore/ADWS/Transfer/DeleteRequest.cs new file mode 100644 index 00000000..e7cac332 --- /dev/null +++ b/SnaffCore/ADWS/Transfer/DeleteRequest.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.ServiceModel.Channels; +using System.ServiceModel; +using System.Text; +using System.Threading.Tasks; +using Microsoft.ActiveDirectory.Management.IMDA; +using System.DirectoryServices.Protocols; +using System.ServiceModel.Description; +using System.Text.RegularExpressions; +using System.Xml.Linq; + +namespace SnaffCore.ADWS.Transfer +{ + internal class DeleteRequest + { + string Instance { get; set; } + string BaseUri { get; set; } + NetworkCredential Credentials { get; set; } + + NetTcpBinding Binding { get; set; } + MessageVersion Version { get; set; } + + public DeleteRequest(ADWSConnection adwsConnection) + { + this.Instance = adwsConnection.Instance; + this.BaseUri = adwsConnection.BaseUri; + this.Binding = adwsConnection.Binding; + this.Credentials = adwsConnection.Credentials; + } + + public Message DeleteRequestMessage(string distinguishedName) + { + var endpointAddress = new System.ServiceModel.EndpointAddress(this.BaseUri + "ActiveDirectoryWebServices/Windows/Resource"); + var resourceClient = new Microsoft.ActiveDirectory.WebServices.Proxy.ResourceClient(this.Binding, endpointAddress); + UpdateCredentials(resourceClient.ClientCredentials); + + DirectoryControl[] controls = new DirectoryControl[0]; + + ADDeleteRequestMsg Request = new ADDeleteRequestMsg(this.Instance, distinguishedName, controls); + + Message addResponse = resourceClient.Delete(Request); + return addResponse; + } + + public void UpdateCredentials(ClientCredentials c) + { + c.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation; + c.Windows.ClientCredential = this.Credentials; + } + } +} diff --git a/SnaffCore/ADWS/Transfer/GetRequest.cs b/SnaffCore/ADWS/Transfer/GetRequest.cs new file mode 100644 index 00000000..d935f372 --- /dev/null +++ b/SnaffCore/ADWS/Transfer/GetRequest.cs @@ -0,0 +1,57 @@ +using Microsoft.ActiveDirectory.Management.IMDA; +using System; +using System.Collections.Generic; +using System.DirectoryServices.Protocols; +using System.Linq; +using System.Net; +using System.ServiceModel.Channels; +using System.ServiceModel.Description; +using System.ServiceModel; +using System.Text; +using System.Threading.Tasks; + +namespace SnaffCore.ADWS.Transfer +{ + internal class GetRequest + { + string Instance { get; set; } + string BaseUri { get; set; } + NetworkCredential Credentials { get; set; } + + NetTcpBinding Binding { get; set; } + MessageVersion Version { get; set; } + + public GetRequest(ADWSConnection adwsConnection) + { + this.Instance = adwsConnection.Instance; + this.BaseUri = adwsConnection.BaseUri; + this.Binding = adwsConnection.Binding; + this.Credentials = adwsConnection.Credentials; + } + + public List BaseObjectSearchRequest(string distinguishedName, IList attributeList) + { + var endpointAddress = new System.ServiceModel.EndpointAddress(this.BaseUri + "ActiveDirectoryWebServices/Windows/Resource"); + var resourceClient = new Microsoft.ActiveDirectory.WebServices.Proxy.ResourceClient(this.Binding, endpointAddress); + UpdateCredentials(resourceClient.ClientCredentials); + + DirectoryControl[] controls = new DirectoryControl[2]; + controls[0] = new PageResultRequestControl(); + controls[1] = new SecurityDescriptorFlagControl(System.DirectoryServices.Protocols.SecurityMasks.Dacl); + + ADGetRequestMsg Request = new ADGetRequestMsg(this.Instance, distinguishedName, controls, attributeList); + + Message resp = resourceClient.Get(Request); + Console.WriteLine(resp.ToString()); + var adObjects = new List(); + + return adObjects; + } + + public void UpdateCredentials(ClientCredentials c) + { + c.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation; + c.Windows.ClientCredential = this.Credentials; + } + } +} diff --git a/SnaffCore/ADWS/Transfer/PutRequest.cs b/SnaffCore/ADWS/Transfer/PutRequest.cs new file mode 100644 index 00000000..ea70efd6 --- /dev/null +++ b/SnaffCore/ADWS/Transfer/PutRequest.cs @@ -0,0 +1,116 @@ +using Microsoft.ActiveDirectory.Management.IMDA; +using System; +using System.Collections.Generic; +using System.DirectoryServices.Protocols; +using System.Linq; +using System.Net; +using System.ServiceModel; +using System.ServiceModel.Channels; +using System.ServiceModel.Description; +using System.Text; +using System.Threading.Tasks; + +namespace SnaffCore.ADWS.Transfer +{ + internal class PutRequest + { + string Instance { get; set; } + string BaseUri { get; set; } + NetworkCredential Credentials { get; set; } + + NetTcpBinding Binding { get; set; } + MessageVersion Version { get; set; } + + public PutRequest(ADWSConnection adwsConnection) + { + this.Instance = adwsConnection.Instance; + this.BaseUri = adwsConnection.BaseUri; + this.Binding = adwsConnection.Binding; + this.Credentials = adwsConnection.Credentials; + } + + public Message ModifyRequest(string distinguishedName, DirectoryAttributeOperation operation, string attribute, string attributeValue) + { + var endpointAddress = new System.ServiceModel.EndpointAddress(this.BaseUri + "ActiveDirectoryWebServices/Windows/Resource"); + var resourceClient = new Microsoft.ActiveDirectory.WebServices.Proxy.ResourceClient(this.Binding, endpointAddress); + UpdateCredentials(resourceClient.ClientCredentials); + + DirectoryControl[] controls = new DirectoryControl[2]; + controls[0] = new PermissiveModifyControl(); + controls[1] = new SecurityDescriptorFlagControl(); + + DirectoryAttributeModification[] attributeModifications = new DirectoryAttributeModification[1]; + attributeModifications[0] = new DirectoryAttributeModification(); + + if (operation == DirectoryAttributeOperation.Replace) + { + attributeModifications[0].Name = attribute; + attributeModifications[0].Operation = DirectoryAttributeOperation.Replace; + attributeModifications[0].Add(attributeValue); + } + if (operation == DirectoryAttributeOperation.Add) + { + attributeModifications[0].Name = attribute; + attributeModifications[0].Operation = DirectoryAttributeOperation.Add; + attributeModifications[0].Add(attributeValue); + } + if (operation == DirectoryAttributeOperation.Delete) + { + attributeModifications[0].Name = attribute; + attributeModifications[0].Operation = DirectoryAttributeOperation.Delete; + attributeModifications[0].Add(attributeValue); + } + + ADPutRequestMsg Request = new ADPutRequestMsg(this.Instance, distinguishedName, controls, attributeModifications); + + Message modifyResponse = resourceClient.Put(Request); + + return modifyResponse; + } + + public Message ModifyRequest(string distinguishedName, DirectoryAttributeOperation operation, string attribute, byte[] attributeValue) + { + var endpointAddress = new System.ServiceModel.EndpointAddress(this.BaseUri + "ActiveDirectoryWebServices/Windows/Resource"); + var resourceClient = new Microsoft.ActiveDirectory.WebServices.Proxy.ResourceClient(this.Binding, endpointAddress); + UpdateCredentials(resourceClient.ClientCredentials); + + DirectoryControl[] controls = new DirectoryControl[2]; + controls[0] = new PermissiveModifyControl(); + controls[1] = new SecurityDescriptorFlagControl(System.DirectoryServices.Protocols.SecurityMasks.Dacl); + + DirectoryAttributeModification[] attributeModifications = new DirectoryAttributeModification[1]; + attributeModifications[0] = new DirectoryAttributeModification(); + + if (operation == DirectoryAttributeOperation.Replace) + { + attributeModifications[0].Name = attribute; + attributeModifications[0].Operation = DirectoryAttributeOperation.Replace; + attributeModifications[0].Add(attributeValue); + } + if (operation == DirectoryAttributeOperation.Add) + { + attributeModifications[0].Name = attribute; + attributeModifications[0].Operation = DirectoryAttributeOperation.Add; + attributeModifications[0].Add(attributeValue); + } + if (operation == DirectoryAttributeOperation.Delete) + { + attributeModifications[0].Name = attribute; + attributeModifications[0].Operation = DirectoryAttributeOperation.Delete; + attributeModifications[0].Add(attributeValue); + } + + ADPutRequestMsg Request = new ADPutRequestMsg(this.Instance, distinguishedName, controls, attributeModifications); + + Message modifyResponse = resourceClient.Put(Request); + + return modifyResponse; + } + + public void UpdateCredentials(ClientCredentials c) + { + c.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation; + c.Windows.ClientCredential = this.Credentials; + } + } +} diff --git a/SnaffCore/ActiveDirectory/Management/ADException.cs b/SnaffCore/ActiveDirectory/Management/ADException.cs new file mode 100644 index 00000000..444f15a6 --- /dev/null +++ b/SnaffCore/ActiveDirectory/Management/ADException.cs @@ -0,0 +1,119 @@ +using System; +using System.Runtime.Serialization; +using System.Security.Permissions; + +namespace Microsoft.ActiveDirectory.Management +{ + // Token: 0x0200007C RID: 124 + [Serializable] + public class ADException : Exception + { + // Token: 0x060002F3 RID: 755 RVA: 0x000075C5 File Offset: 0x000057C5 + public ADException() + { + } + + // Token: 0x060002F4 RID: 756 RVA: 0x000075CD File Offset: 0x000057CD + public ADException(string message) + : base(message) + { + } + + // Token: 0x060002F5 RID: 757 RVA: 0x000075D6 File Offset: 0x000057D6 + public ADException(string message, Exception innerException) + : base(message, innerException) + { + } + + // Token: 0x060002F6 RID: 758 RVA: 0x000075E0 File Offset: 0x000057E0 + protected ADException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + this._errorCode = info.GetInt32("errorCode"); + this._serverErrorMessage = (string)info.GetValue("serverErrorMessage", typeof(string)); + } + + // Token: 0x060002F7 RID: 759 RVA: 0x0000761B File Offset: 0x0000581B + public ADException(string message, int errorCode) + : base(message) + { + this._errorCode = errorCode; + } + + // Token: 0x060002F8 RID: 760 RVA: 0x0000762B File Offset: 0x0000582B + public ADException(string message, Exception inner, int errorCode) + : base(message, inner) + { + this._errorCode = errorCode; + } + + // Token: 0x060002F9 RID: 761 RVA: 0x0000763C File Offset: 0x0000583C + public ADException(string message, string serverErrorMessage) + : base(message) + { + this._serverErrorMessage = serverErrorMessage; + } + + // Token: 0x060002FA RID: 762 RVA: 0x0000764C File Offset: 0x0000584C + public ADException(string message, int errorCode, string serverErrorMessage) + : base(message) + { + this._errorCode = errorCode; + this._serverErrorMessage = serverErrorMessage; + } + + // Token: 0x060002FB RID: 763 RVA: 0x00007663 File Offset: 0x00005863 + public ADException(string message, Exception inner, string serverErrorMessage) + : base(message, inner) + { + this._serverErrorMessage = serverErrorMessage; + } + + // Token: 0x060002FC RID: 764 RVA: 0x00007674 File Offset: 0x00005874 + public ADException(string message, Exception inner, int errorCode, string serverErrorMessage) + : base(message, inner) + { + this._errorCode = errorCode; + this._serverErrorMessage = serverErrorMessage; + } + + // Token: 0x170000E2 RID: 226 + // (get) Token: 0x060002FD RID: 765 RVA: 0x0000768D File Offset: 0x0000588D + public int ErrorCode + { + get + { + return this._errorCode; + } + } + + // Token: 0x170000E3 RID: 227 + // (get) Token: 0x060002FE RID: 766 RVA: 0x00007695 File Offset: 0x00005895 + public string ServerErrorMessage + { + get + { + return this._serverErrorMessage; + } + } + + // Token: 0x060002FF RID: 767 RVA: 0x000076A0 File Offset: 0x000058A0 + [SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)] + public override void GetObjectData(SerializationInfo info, StreamingContext streamingContext) + { + if (info == null) + { + throw new ArgumentNullException("info"); + } + info.AddValue("errorCode", this._errorCode); + info.AddValue("serverErrorMessage", this._serverErrorMessage, typeof(string)); + base.GetObjectData(info, streamingContext); + } + + // Token: 0x0400030D RID: 781 + private int _errorCode; + + // Token: 0x0400030E RID: 782 + private string _serverErrorMessage; + } +} diff --git a/SnaffCore/ActiveDirectory/Management/ADValueSerializer.cs b/SnaffCore/ActiveDirectory/Management/ADValueSerializer.cs new file mode 100644 index 00000000..f17fc583 --- /dev/null +++ b/SnaffCore/ActiveDirectory/Management/ADValueSerializer.cs @@ -0,0 +1,154 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Xml; + +namespace Microsoft.ActiveDirectory.Management +{ + // Token: 0x020000BC RID: 188 + internal sealed class ADValueSerializer + { + // Token: 0x0600050C RID: 1292 RVA: 0x0001250C File Offset: 0x0001070C + private ADValueSerializer() + { + } + + // Token: 0x0600050D RID: 1293 RVA: 0x00012514 File Offset: 0x00010714 + static ADValueSerializer() + { + ADValueSerializer._typeMappingToClr.Add("string", typeof(string)); + ADValueSerializer._typeMappingToClr.Add("base64Binary", typeof(byte[])); + ADValueSerializer._typeMappingToClr.Add("boolean", typeof(bool)); + ADValueSerializer._typeMappingToClr.Add("int", typeof(int)); + ADValueSerializer._typeMappingToClr.Add("long", typeof(long)); + ADValueSerializer._typeMappingToClr.Add("dateTime", typeof(DateTime)); + } + + // Token: 0x0600050E RID: 1294 RVA: 0x000125C4 File Offset: 0x000107C4 + private static void Deserialize(XmlReader reader, bool useInternStrings, out object value, out Type type) + { + object obj = null; + List list = null; + int num = 0; + type = null; + while (reader.IsStartElement("value", "http://schemas.microsoft.com/2008/1/ActiveDirectory")) + { + num++; + if (num > 1 && list == null) + { + list = new List(); + list.Add(obj); + } + string text; + string text2; + XmlUtility.SplitPrefix(reader.GetAttribute("type", "http://www.w3.org/2001/XMLSchema-instance"), out text, out text2); + type = ADValueSerializer._typeMappingToClr[text2]; + obj = reader.ReadElementContentAs(type, null, "value", "http://schemas.microsoft.com/2008/1/ActiveDirectory"); + if (list != null) + { + if (useInternStrings && type == typeof(string)) + { + list.Add(string.Intern((string)obj)); + } + else + { + list.Add(obj); + } + } + } + value = ((list == null) ? obj : list.ToArray()); + } + + // Token: 0x0600050F RID: 1295 RVA: 0x00012688 File Offset: 0x00010888 + public static void DeserializeSingleValue(XmlReader reader, out T value) + { + object obj; + Type type; + ADValueSerializer.Deserialize(reader, false, out obj, out type); + value = (T)((object)obj); + } + + // Token: 0x06000510 RID: 1296 RVA: 0x000126AC File Offset: 0x000108AC + public static void Serialize(XmlDictionaryWriter writer, object value) + { + bool flag = false; + writer.LookupPrefix("http://www.w3.org/2001/XMLSchema"); + writer.WriteStartElement("value", "http://schemas.microsoft.com/2008/1/ActiveDirectory"); + string text; + bool flag2; + if (!(value.GetType() == typeof(byte[]))) + { + switch (Type.GetTypeCode(value.GetType())) + { + case TypeCode.Boolean: + text = "boolean"; + flag2 = false; + value = (((bool)value) ? "true" : "false"); + goto IL_11E; + case TypeCode.Char: + case TypeCode.SByte: + case TypeCode.Int16: + case TypeCode.UInt16: + case TypeCode.Int32: + case TypeCode.UInt32: + text = "int"; + flag2 = false; + goto IL_11E; + case TypeCode.Byte: + text = "base64Binary"; + flag2 = true; + flag = false; + goto IL_11E; + case TypeCode.Int64: + case TypeCode.UInt64: + text = "long"; + flag2 = false; + goto IL_11E; + case TypeCode.DateTime: + text = "dateTime"; + flag2 = false; + value = XmlConvert.ToString((DateTime)value, XmlDateTimeSerializationMode.Utc); + goto IL_11E; + case TypeCode.String: + text = "string"; + flag2 = false; + goto IL_11E; + } + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.ADWSXmlParserUnexpectedElement, value.GetType().ToString())); + } + flag2 = true; + flag = true; + text = "base64Binary"; + IL_11E: + XmlUtility.WriteXsiTypeAttribute(writer, text); + if (flag2) + { + byte[] array; + if (flag) + { + array = (byte[])value; + } + else + { + array = new byte[] { (byte)value }; + } + writer.WriteBase64(array, 0, array.Length); + } + else + { + writer.WriteString(value.ToString()); + } + writer.WriteEndElement(); + } + + // Token: 0x06000511 RID: 1297 RVA: 0x00012824 File Offset: 0x00010A24 + public static void Deserialize(XmlReader reader, bool useInternStrings, out object value) + { + Type type; + ADValueSerializer.Deserialize(reader, useInternStrings, out value, out type); + } + + // Token: 0x040004C3 RID: 1219 + private static Dictionary _typeMappingToClr = new Dictionary(6); + } +} diff --git a/SnaffCore/ActiveDirectory/Management/AdimdaRequestMsg.cs b/SnaffCore/ActiveDirectory/Management/AdimdaRequestMsg.cs new file mode 100644 index 00000000..23045b10 --- /dev/null +++ b/SnaffCore/ActiveDirectory/Management/AdimdaRequestMsg.cs @@ -0,0 +1,37 @@ +using System; +using System.ServiceModel.Channels; +using System.Xml; + +namespace Microsoft.ActiveDirectory.Management +{ + // Token: 0x020000BA RID: 186 + internal abstract class AdimdaRequestMsg : AdwsRequestMsg + { + // Token: 0x06000506 RID: 1286 RVA: 0x000124A1 File Offset: 0x000106A1 + protected AdimdaRequestMsg(string instance) + : base(instance) + { + this.AddHeaders(); + } + + // Token: 0x06000507 RID: 1287 RVA: 0x000124B0 File Offset: 0x000106B0 + protected AdimdaRequestMsg(string instance, string objectReferenceProperty) + : base(instance, objectReferenceProperty) + { + this.AddHeaders(); + } + + // Token: 0x06000508 RID: 1288 RVA: 0x000124C0 File Offset: 0x000106C0 + private void AddHeaders() + { + this.Headers.Add(MessageHeader.CreateHeader("IdentityManagementOperation", "http://schemas.microsoft.com/2006/11/IdentityManagement/DirectoryAccess", new object(), true)); + } + + // Token: 0x06000509 RID: 1289 RVA: 0x000124E2 File Offset: 0x000106E2 + protected override void OnWriteStartEnvelope(XmlDictionaryWriter writer) + { + base.OnWriteStartEnvelope(writer); + writer.WriteXmlnsAttribute("da", "http://schemas.microsoft.com/2006/11/IdentityManagement/DirectoryAccess"); + } + } +} diff --git a/SnaffCore/ActiveDirectory/Management/AdwsMessage.cs b/SnaffCore/ActiveDirectory/Management/AdwsMessage.cs new file mode 100644 index 00000000..6fac40be --- /dev/null +++ b/SnaffCore/ActiveDirectory/Management/AdwsMessage.cs @@ -0,0 +1,79 @@ +using System; +using System.ServiceModel.Channels; +using System.Text; +using System.Xml; + +namespace Microsoft.ActiveDirectory.Management +{ + // Token: 0x020000B7 RID: 183 + internal abstract class AdwsMessage : Message + { + // Token: 0x060004E0 RID: 1248 RVA: 0x0001205A File Offset: 0x0001025A + protected AdwsMessage() + { + } + + // Token: 0x060004E1 RID: 1249 RVA: 0x00012062 File Offset: 0x00010262 + private AdwsMessage(Message msg) + { + } + + // Token: 0x060004E2 RID: 1250 RVA: 0x0001206A File Offset: 0x0001026A + internal static MessageBuffer MessageToBuffer(Message msg) + { + return msg.CreateBufferedCopy(int.MaxValue); + } + + // Token: 0x060004E3 RID: 1251 RVA: 0x00012077 File Offset: 0x00010277 + internal static Message BufferToMessage(MessageBuffer buffer) + { + return buffer.CreateMessage(); + } + + // Token: 0x060004E4 RID: 1252 RVA: 0x00012080 File Offset: 0x00010280 + internal static string MessageToString(Message msg, bool indent) + { + MessageBuffer messageBuffer = msg.CreateBufferedCopy(5242880); + XmlWriterSettings xmlWriterSettings = new XmlWriterSettings(); + xmlWriterSettings.OmitXmlDeclaration = true; + xmlWriterSettings.ConformanceLevel = ConformanceLevel.Fragment; + xmlWriterSettings.Encoding = Encoding.UTF8; + if (indent) + { + xmlWriterSettings.Indent = true; + xmlWriterSettings.IndentChars = " "; + xmlWriterSettings.NewLineOnAttributes = false; + } + StringBuilder stringBuilder = new StringBuilder(); + XmlWriter xmlWriter = XmlWriter.Create(stringBuilder, xmlWriterSettings); + XmlDictionaryWriter xmlDictionaryWriter = XmlDictionaryWriter.CreateDictionaryWriter(xmlWriter); + messageBuffer.CreateMessage().WriteMessage(xmlDictionaryWriter); + xmlWriter.Flush(); + xmlDictionaryWriter.Close(); + return stringBuilder.ToString(); + } + + // Token: 0x060004E5 RID: 1253 RVA: 0x00012103 File Offset: 0x00010303 + protected override void OnWriteStartHeaders(XmlDictionaryWriter writer) + { + base.OnWriteStartHeaders(writer); + } + + // Token: 0x060004E6 RID: 1254 RVA: 0x0001210C File Offset: 0x0001030C + protected override void OnWriteStartEnvelope(XmlDictionaryWriter writer) + { + base.OnWriteStartEnvelope(writer); + } + + // Token: 0x060004E7 RID: 1255 RVA: 0x00012115 File Offset: 0x00010315 + protected override void OnWriteBodyContents(XmlDictionaryWriter writer) + { + } + + // Token: 0x060004E8 RID: 1256 RVA: 0x00012117 File Offset: 0x00010317 + public virtual string ToString(bool indent) + { + return AdwsMessage.MessageToString(this, indent); + } + } +} diff --git a/SnaffCore/ActiveDirectory/Management/AdwsRequestMsg.cs b/SnaffCore/ActiveDirectory/Management/AdwsRequestMsg.cs new file mode 100644 index 00000000..0d08d4a1 --- /dev/null +++ b/SnaffCore/ActiveDirectory/Management/AdwsRequestMsg.cs @@ -0,0 +1,105 @@ +using System; +using System.ServiceModel.Channels; +using System.Xml; + +namespace Microsoft.ActiveDirectory.Management +{ + // Token: 0x020000B8 RID: 184 + internal abstract class AdwsRequestMsg : AdwsMessage + { + // Token: 0x060004E9 RID: 1257 RVA: 0x00012120 File Offset: 0x00010320 + private AdwsRequestMsg() + { + } + + // Token: 0x060004EA RID: 1258 RVA: 0x00012134 File Offset: 0x00010334 + protected AdwsRequestMsg(string instance) + { + this._messageHeaders = new MessageHeaders(this.Version, 7); + this.Headers.Action = this.Action; + this.Headers.Add(MessageHeader.CreateHeader("instance", "http://schemas.microsoft.com/2008/1/ActiveDirectory", instance)); + } + + // Token: 0x060004EB RID: 1259 RVA: 0x00012190 File Offset: 0x00010390 + protected AdwsRequestMsg(string instance, string objectReferenceProperty) + : this(instance) + { + if (!string.IsNullOrEmpty(objectReferenceProperty)) + { + this.Headers.Add(MessageHeader.CreateHeader("objectReferenceProperty", "http://schemas.microsoft.com/2008/1/ActiveDirectory", objectReferenceProperty)); + } + } + + // Token: 0x17000120 RID: 288 + // (get) Token: 0x060004EC RID: 1260 RVA: 0x000121BC File Offset: 0x000103BC + public override MessageHeaders Headers + { + get + { + return this._messageHeaders; + } + } + + // Token: 0x17000121 RID: 289 + // (get) Token: 0x060004ED RID: 1261 RVA: 0x000121C4 File Offset: 0x000103C4 + public override MessageProperties Properties + { + get + { + return this._messageProperties; + } + } + + // Token: 0x17000122 RID: 290 + // (get) Token: 0x060004EE RID: 1262 + public abstract string Action { get; } + + // Token: 0x17000123 RID: 291 + // (get) Token: 0x060004EF RID: 1263 RVA: 0x000121CC File Offset: 0x000103CC + public override MessageVersion Version + { + get + { + return MessageVersion.Soap12WSAddressing10; + } + } + + // Token: 0x060004F0 RID: 1264 RVA: 0x000121D3 File Offset: 0x000103D3 + protected virtual void AddPrefixIfNeeded(XmlDictionaryWriter writer, string prefix, string ns) + { + if (writer.LookupPrefix(ns) == null) + { + writer.WriteXmlnsAttribute(prefix, ns); + } + } + + // Token: 0x060004F1 RID: 1265 RVA: 0x000121E6 File Offset: 0x000103E6 + protected override void OnWriteStartHeaders(XmlDictionaryWriter writer) + { + base.OnWriteStartHeaders(writer); + } + + // Token: 0x060004F2 RID: 1266 RVA: 0x000121F0 File Offset: 0x000103F0 + protected override void OnWriteStartEnvelope(XmlDictionaryWriter writer) + { + base.OnWriteStartEnvelope(writer); + writer.WriteXmlnsAttribute("addata", "http://schemas.microsoft.com/2008/1/ActiveDirectory/Data"); + writer.WriteXmlnsAttribute("ad", "http://schemas.microsoft.com/2008/1/ActiveDirectory"); + writer.WriteXmlnsAttribute("xsd", "http://www.w3.org/2001/XMLSchema"); + writer.WriteXmlnsAttribute("xsi", "http://www.w3.org/2001/XMLSchema-instance"); + if (writer.LookupPrefix("http://www.w3.org/2005/08/addressing") == null) + { + writer.WriteXmlnsAttribute("wsa", "http://www.w3.org/2005/08/addressing"); + } + } + + // Token: 0x040004BC RID: 1212 + private MessageHeaders _messageHeaders; + + // Token: 0x040004BD RID: 1213 + private MessageProperties _messageProperties = new MessageProperties(); + + // Token: 0x040004BE RID: 1214 + private const int _initialHeaderBufferSize = 7; + } +} diff --git a/SnaffCore/ActiveDirectory/Management/AttributeNs.cs b/SnaffCore/ActiveDirectory/Management/AttributeNs.cs new file mode 100644 index 00000000..348c011e --- /dev/null +++ b/SnaffCore/ActiveDirectory/Management/AttributeNs.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; + +namespace Microsoft.ActiveDirectory.Management +{ + // Token: 0x020000B6 RID: 182 + internal class AttributeNs + { + // Token: 0x060004DB RID: 1243 RVA: 0x00011F59 File Offset: 0x00010159 + private AttributeNs() + { + } + + // Token: 0x060004DC RID: 1244 RVA: 0x00011F64 File Offset: 0x00010164 + static AttributeNs() + { + AttributeNs._SyntheticNsDict.Add("objectReferenceProperty", SyntheticAttributeOperation.Read | SyntheticAttributeOperation.Write); + AttributeNs._SyntheticNsDict.Add("container-hierarchy-parent", SyntheticAttributeOperation.Read | SyntheticAttributeOperation.Write); + AttributeNs._SyntheticNsDict.Add("relativeDistinguishedName", SyntheticAttributeOperation.Read | SyntheticAttributeOperation.Write); + AttributeNs._SyntheticNsDict.Add("ad:all", SyntheticAttributeOperation.Read | SyntheticAttributeOperation.Write); + AttributeNs._SyntheticNsDict.Add("distinguishedName", SyntheticAttributeOperation.Read); + } + + // Token: 0x060004DD RID: 1245 RVA: 0x00011FCC File Offset: 0x000101CC + public static string LookupNs(string attribute, SyntheticAttributeOperation operation) + { + SyntheticAttributeOperation syntheticAttributeOperation; + if (!AttributeNs._SyntheticNsDict.TryGetValue(attribute, out syntheticAttributeOperation)) + { + return "http://schemas.microsoft.com/2008/1/ActiveDirectory/Data"; + } + if (string.Equals(attribute, "ad:all", StringComparison.Ordinal)) + { + return string.Empty; + } + if (operation != (syntheticAttributeOperation & operation)) + { + return "http://schemas.microsoft.com/2008/1/ActiveDirectory/Data"; + } + return "http://schemas.microsoft.com/2008/1/ActiveDirectory"; + } + + // Token: 0x060004DE RID: 1246 RVA: 0x00012014 File Offset: 0x00010214 + public static bool IsSynthetic(string attribute, SyntheticAttributeOperation operation) + { + SyntheticAttributeOperation syntheticAttributeOperation; + return AttributeNs._SyntheticNsDict.TryGetValue(attribute, out syntheticAttributeOperation) && operation == (syntheticAttributeOperation & operation); + } + + // Token: 0x060004DF RID: 1247 RVA: 0x00012038 File Offset: 0x00010238 + public static bool IsSynthetic(string attribute, SyntheticAttributeOperation operation, ref bool hasPrefix) + { + hasPrefix = false; + if (AttributeNs.IsSynthetic(attribute, operation)) + { + if (string.Equals(attribute, "ad:all", StringComparison.Ordinal)) + { + hasPrefix = true; + } + return true; + } + return false; + } + + // Token: 0x040004BB RID: 1211 + private static Dictionary _SyntheticNsDict = new Dictionary(5); + } +} diff --git a/SnaffCore/ActiveDirectory/Management/AttributeTypeAndValueSerializer.cs b/SnaffCore/ActiveDirectory/Management/AttributeTypeAndValueSerializer.cs new file mode 100644 index 00000000..cf176401 --- /dev/null +++ b/SnaffCore/ActiveDirectory/Management/AttributeTypeAndValueSerializer.cs @@ -0,0 +1,134 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.DirectoryServices.Protocols; +using System.Xml; + +namespace Microsoft.ActiveDirectory.Management +{ + // Token: 0x020000C0 RID: 192 + internal sealed class AttributeTypeAndValueSerializer + { + // Token: 0x06000520 RID: 1312 RVA: 0x00012A94 File Offset: 0x00010C94 + private AttributeTypeAndValueSerializer() + { + } + + // Token: 0x06000521 RID: 1313 RVA: 0x00012A9C File Offset: 0x00010C9C + private static string FormatAttributeName(string prefix, string attribute) + { + return XmlUtility.AddPrefix(prefix, attribute); + } + + // Token: 0x06000522 RID: 1314 RVA: 0x00012AA8 File Offset: 0x00010CA8 + private static void InternalSerialize(XmlDictionaryWriter writer, ChangeOperation ChangeOperation, string ns, string property, object value) + { + string text = writer.LookupPrefix(ns); + writer.LookupPrefix("http://schemas.microsoft.com/2008/1/ActiveDirectory"); + if (ChangeOperation == ChangeOperation.None) + { + writer.WriteStartElement("AttributeTypeAndValue", "http://schemas.microsoft.com/2006/11/IdentityManagement/DirectoryAccess"); + } + else + { + writer.WriteStartElement("Change", "http://schemas.microsoft.com/2006/11/IdentityManagement/DirectoryAccess"); + switch (ChangeOperation) + { + case ChangeOperation.Add: + writer.WriteAttributeString("Operation", "add"); + break; + case ChangeOperation.Delete: + writer.WriteAttributeString("Operation", "delete"); + break; + case ChangeOperation.Replace: + writer.WriteAttributeString("Operation", "replace"); + break; + } + } + writer.WriteElementString("AttributeType", "http://schemas.microsoft.com/2006/11/IdentityManagement/DirectoryAccess", AttributeTypeAndValueSerializer.FormatAttributeName(text, property)); + if (value != null) + { + if (value is ICollection) + { + ICollection collection = (ICollection)value; + if (collection.Count > 0) + { + writer.WriteStartElement("AttributeValue", "http://schemas.microsoft.com/2006/11/IdentityManagement/DirectoryAccess"); + foreach (object obj in collection) + { + ADValueSerializer.Serialize(writer, obj); + } + writer.WriteEndElement(); + } + } + else + { + writer.WriteStartElement("AttributeValue", "http://schemas.microsoft.com/2006/11/IdentityManagement/DirectoryAccess"); + if (value is DirectoryAttributeModification) + { + DirectoryAttributeModification directoryAttributeModification = (DirectoryAttributeModification)value; + ADValueSerializer.Serialize(writer, directoryAttributeModification[0]); + } + else + { + ADValueSerializer.Serialize(writer, value); + } + writer.WriteEndElement(); + } + } + writer.WriteEndElement(); + } + + // Token: 0x06000523 RID: 1315 RVA: 0x00012C18 File Offset: 0x00010E18 + public static void Serialize(XmlDictionaryWriter writer, DirectoryAttribute attribute) + { + AttributeTypeAndValueSerializer.InternalSerialize(writer, ChangeOperation.None, AttributeNs.LookupNs(attribute.Name, SyntheticAttributeOperation.Write), attribute.Name, attribute); + } + + // Token: 0x06000524 RID: 1316 RVA: 0x00012C34 File Offset: 0x00010E34 + public static void Serialize(XmlDictionaryWriter writer, ChangeOperation ChangeOperation, DirectoryAttributeModification attribute) + { + AttributeTypeAndValueSerializer.InternalSerialize(writer, ChangeOperation, AttributeNs.LookupNs(attribute.Name, SyntheticAttributeOperation.Write), attribute.Name, attribute); + } + + // Token: 0x06000525 RID: 1317 RVA: 0x00012C50 File Offset: 0x00010E50 + public static void Serialize(XmlDictionaryWriter writer, DirectoryAttributeModification attribute) + { + ChangeOperation changeOperation = ChangeOperation.None; + switch (attribute.Operation) + { + case DirectoryAttributeOperation.Add: + changeOperation = ChangeOperation.Add; + break; + case DirectoryAttributeOperation.Delete: + changeOperation = ChangeOperation.Delete; + break; + case DirectoryAttributeOperation.Replace: + changeOperation = ChangeOperation.Replace; + break; + } + AttributeTypeAndValueSerializer.InternalSerialize(writer, changeOperation, AttributeNs.LookupNs(attribute.Name, SyntheticAttributeOperation.Write), attribute.Name, attribute); + } + + // Token: 0x06000526 RID: 1318 RVA: 0x00012C9E File Offset: 0x00010E9E + public static void Serialize(XmlDictionaryWriter writer, string ns, string property, object value) + { + AttributeTypeAndValueSerializer.InternalSerialize(writer, ChangeOperation.None, ns, property, value); + } + + // Token: 0x06000527 RID: 1319 RVA: 0x00012CAA File Offset: 0x00010EAA + public static void Serialize(XmlDictionaryWriter writer, ChangeOperation ChangeOperation, string ns, string property, object value) + { + AttributeTypeAndValueSerializer.InternalSerialize(writer, ChangeOperation, ns, property, value); + } + + // Token: 0x06000528 RID: 1320 RVA: 0x00012CB8 File Offset: 0x00010EB8 + public static void Serialize(XmlDictionaryWriter writer, ChangeOperation ChangeOperation, IList attributes) + { + foreach (DirectoryAttributeModification directoryAttributeModification in attributes) + { + AttributeTypeAndValueSerializer.InternalSerialize(writer, ChangeOperation, AttributeNs.LookupNs(directoryAttributeModification.Name, SyntheticAttributeOperation.Write), directoryAttributeModification.Name, directoryAttributeModification); + } + } + } +} diff --git a/SnaffCore/ActiveDirectory/Management/ChangeOperation.cs b/SnaffCore/ActiveDirectory/Management/ChangeOperation.cs new file mode 100644 index 00000000..e5e27e51 --- /dev/null +++ b/SnaffCore/ActiveDirectory/Management/ChangeOperation.cs @@ -0,0 +1,17 @@ +using System; + +namespace Microsoft.ActiveDirectory.Management +{ + // Token: 0x020000BF RID: 191 + internal enum ChangeOperation + { + // Token: 0x040004CA RID: 1226 + None, + // Token: 0x040004CB RID: 1227 + Add, + // Token: 0x040004CC RID: 1228 + Delete, + // Token: 0x040004CD RID: 1229 + Replace + } +} diff --git a/SnaffCore/ActiveDirectory/Management/DirectoryControlSerializer.cs b/SnaffCore/ActiveDirectory/Management/DirectoryControlSerializer.cs new file mode 100644 index 00000000..f918b382 --- /dev/null +++ b/SnaffCore/ActiveDirectory/Management/DirectoryControlSerializer.cs @@ -0,0 +1,80 @@ +using System; +using System.Collections.Generic; +using System.DirectoryServices.Protocols; +using System.Xml; + +namespace Microsoft.ActiveDirectory.Management +{ + // Token: 0x020000BE RID: 190 + internal sealed class DirectoryControlSerializer + { + // Token: 0x0600051D RID: 1309 RVA: 0x000128A3 File Offset: 0x00010AA3 + private DirectoryControlSerializer() + { + } + + // Token: 0x0600051E RID: 1310 RVA: 0x000128AC File Offset: 0x00010AAC + public static void Serialize(XmlDictionaryWriter writer, IList controls) + { + if (controls == null || controls.Count == 0) + { + return; + } + writer.WriteStartElement("ad", "controls", "http://schemas.microsoft.com/2008/1/ActiveDirectory"); + foreach (DirectoryControl directoryControl in controls) + { + byte[] value = directoryControl.GetValue(); + writer.WriteStartElement("ad", "control", "http://schemas.microsoft.com/2008/1/ActiveDirectory"); + writer.WriteAttributeString("type", directoryControl.Type.ToLowerInvariant()); + writer.WriteAttributeString("criticality", directoryControl.IsCritical ? "true" : "false"); + if (value != null && value.Length != 0) + { + writer.WriteStartElement("ad", "controlValue", "http://schemas.microsoft.com/2008/1/ActiveDirectory"); + XmlUtility.WriteXsiTypeAttribute(writer, "base64Binary"); + writer.WriteBase64(value, 0, value.Length); + writer.WriteEndElement(); + } + writer.WriteEndElement(); + } + writer.WriteEndElement(); + } + + // Token: 0x0600051F RID: 1311 RVA: 0x000129AC File Offset: 0x00010BAC + public static void Deserialize(XmlDictionaryReader reader, out IList controls, bool mustBePresent, bool fullChecks) + { + controls = new List(); + if (!mustBePresent && !reader.IsStartElement("controls", "http://schemas.microsoft.com/2008/1/ActiveDirectory")) + { + return; + } + reader.ReadFullStartElement("controls", "http://schemas.microsoft.com/2008/1/ActiveDirectory"); + while (reader.IsStartElement("control", "http://schemas.microsoft.com/2008/1/ActiveDirectory")) + { + string attribute = reader.GetAttribute("type"); + string attribute2 = reader.GetAttribute("criticality"); + reader.Read(); + byte[] array; + if (reader.IsStartElement("controlValue", "http://schemas.microsoft.com/2008/1/ActiveDirectory")) + { + string attribute3 = reader.GetAttribute("type", "http://www.w3.org/2001/XMLSchema-instance"); + if (attribute3 == null) + { + throw new ArgumentException(); + } + string text; + string text2; + XmlUtility.SplitPrefix(attribute3, out text, out text2); + array = reader.ReadElementContentAsBase64(); + } + else + { + array = null; + } + bool flag = string.Equals("true", attribute2); + DirectoryControl directoryControl = new DirectoryControl(attribute, array, flag, true); + controls.Add(directoryControl); + reader.Read(); + } + } + } +} diff --git a/SnaffCore/ActiveDirectory/Management/IMDA/ADCreateRequestMsg.cs b/SnaffCore/ActiveDirectory/Management/IMDA/ADCreateRequestMsg.cs new file mode 100644 index 00000000..aea46904 --- /dev/null +++ b/SnaffCore/ActiveDirectory/Management/IMDA/ADCreateRequestMsg.cs @@ -0,0 +1,70 @@ +using System; +using System.Collections.Generic; +using System.DirectoryServices.Protocols; +using System.Xml; + +namespace Microsoft.ActiveDirectory.Management.IMDA +{ + // Token: 0x02000306 RID: 774 + internal class ADCreateRequestMsg : AdimdaRequestMsg + { + // Token: 0x06001AB5 RID: 6837 RVA: 0x00052B5C File Offset: 0x00050D5C + public ADCreateRequestMsg(string instance, string parent, string relativeDistinguishedName, IList controls) + : base(instance, null) + { + this._relativeDistinguishedName = relativeDistinguishedName; + this._parentContainer = parent; + this._controls = controls; + } + + // Token: 0x06001AB6 RID: 6838 RVA: 0x00052B7C File Offset: 0x00050D7C + public ADCreateRequestMsg(string instance, string parent, string relativeDistinguishedName, IList controls, IList attributes) + : this(instance, parent, relativeDistinguishedName, controls) + { + this._attributes = attributes; + } + + // Token: 0x1700090E RID: 2318 + // (get) Token: 0x06001AB7 RID: 6839 RVA: 0x00052B91 File Offset: 0x00050D91 + public override string Action + { + get + { + return "http://schemas.xmlsoap.org/ws/2004/09/transfer/Create"; + } + } + + // Token: 0x06001AB8 RID: 6840 RVA: 0x00052B98 File Offset: 0x00050D98 + protected override void OnWriteBodyContents(XmlDictionaryWriter writer) + { + writer.WriteStartElement("AddRequest", "http://schemas.microsoft.com/2006/11/IdentityManagement/DirectoryAccess"); + writer.WriteAttributeString("Dialect", "http://schemas.microsoft.com/2008/1/ActiveDirectory/Dialect/XPath-Level-1"); + if (this._attributes != null) + { + foreach (DirectoryAttribute directoryAttribute in this._attributes) + { + AttributeTypeAndValueSerializer.Serialize(writer, directoryAttribute); + } + } + AttributeTypeAndValueSerializer.Serialize(writer, "http://schemas.microsoft.com/2008/1/ActiveDirectory", "relativeDistinguishedName", this._relativeDistinguishedName); + AttributeTypeAndValueSerializer.Serialize(writer, "http://schemas.microsoft.com/2008/1/ActiveDirectory", "container-hierarchy-parent", this._parentContainer); + if (this._controls != null) + { + DirectoryControlSerializer.Serialize(writer, this._controls); + } + writer.WriteEndElement(); + } + + // Token: 0x04000C74 RID: 3188 + private IList _controls; + + // Token: 0x04000C75 RID: 3189 + private IList _attributes; + + // Token: 0x04000C76 RID: 3190 + private string _relativeDistinguishedName; + + // Token: 0x04000C77 RID: 3191 + private string _parentContainer; + } +} diff --git a/SnaffCore/ActiveDirectory/Management/IMDA/ADDeleteRequestMsg.cs b/SnaffCore/ActiveDirectory/Management/IMDA/ADDeleteRequestMsg.cs new file mode 100644 index 00000000..f54aa367 --- /dev/null +++ b/SnaffCore/ActiveDirectory/Management/IMDA/ADDeleteRequestMsg.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.DirectoryServices.Protocols; +using System.Xml; + +namespace Microsoft.ActiveDirectory.Management.IMDA +{ + // Token: 0x02000302 RID: 770 + internal class ADDeleteRequestMsg : AdwsRequestMsg + { + // Token: 0x06001AA0 RID: 6816 RVA: 0x000529AF File Offset: 0x00050BAF + public ADDeleteRequestMsg(string instance, string objectReference, IList controls) + : base(instance, objectReference) + { + this._controls = controls; + } + + // Token: 0x17000905 RID: 2309 + // (get) Token: 0x06001AA1 RID: 6817 RVA: 0x000529C0 File Offset: 0x00050BC0 + public override string Action + { + get + { + return "http://schemas.xmlsoap.org/ws/2004/09/transfer/Delete"; + } + } + + // Token: 0x06001AA2 RID: 6818 RVA: 0x000529C7 File Offset: 0x00050BC7 + protected override void OnWriteBodyContents(XmlDictionaryWriter writer) + { + base.OnWriteBodyContents(writer); + if (this._controls != null) + { + DirectoryControlSerializer.Serialize(writer, this._controls); + } + } + + // Token: 0x04000C6F RID: 3183 + private IList _controls; + } +} diff --git a/SnaffCore/ActiveDirectory/Management/IMDA/ADGetRequestMsg.cs b/SnaffCore/ActiveDirectory/Management/IMDA/ADGetRequestMsg.cs new file mode 100644 index 00000000..dd7480ec --- /dev/null +++ b/SnaffCore/ActiveDirectory/Management/IMDA/ADGetRequestMsg.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.DirectoryServices.Protocols; +using System.Xml; + +namespace Microsoft.ActiveDirectory.Management.IMDA +{ + // Token: 0x02000308 RID: 776 + internal class ADGetRequestMsg : AdimdaRequestMsg + { + // Token: 0x06001AC0 RID: 6848 RVA: 0x00052D3C File Offset: 0x00050F3C + public ADGetRequestMsg(string instance, string objectReference, IList controls, IList attributeList) + : base(instance, objectReference) + { + if (attributeList == null || attributeList.Count == 0) + { + throw new ArgumentOutOfRangeException("attributeList"); + } + this._controls = controls; + this._attributeList = attributeList; + } + + // Token: 0x17000912 RID: 2322 + // (get) Token: 0x06001AC1 RID: 6849 RVA: 0x00052D6D File Offset: 0x00050F6D + public override string Action + { + get + { + return "http://schemas.xmlsoap.org/ws/2004/09/transfer/Get"; + } + } + + // Token: 0x06001AC2 RID: 6850 RVA: 0x00052D74 File Offset: 0x00050F74 + protected override void OnWriteBodyContents(XmlDictionaryWriter writer) + { + writer.WriteStartElement("BaseObjectSearchRequest", "http://schemas.microsoft.com/2006/11/IdentityManagement/DirectoryAccess"); + writer.WriteAttributeString("Dialect", "http://schemas.microsoft.com/2008/1/ActiveDirectory/Dialect/XPath-Level-1"); + base.OnWriteBodyContents(writer); + string text = writer.LookupPrefix("http://schemas.microsoft.com/2008/1/ActiveDirectory/Data"); + string text2 = writer.LookupPrefix("http://schemas.microsoft.com/2008/1/ActiveDirectory"); + if (this._attributeList != null) + { + XmlUtility.SerializeAttributeList(writer, "AttributeType", "http://schemas.microsoft.com/2006/11/IdentityManagement/DirectoryAccess", text2, text, this._attributeList); + } + if (this._controls != null) + { + DirectoryControlSerializer.Serialize(writer, this._controls); + } + writer.WriteEndElement(); + } + + // Token: 0x04000C7B RID: 3195 + private IList _controls; + + // Token: 0x04000C7C RID: 3196 + private IList _attributeList; + } +} diff --git a/SnaffCore/ActiveDirectory/Management/IMDA/ADPutRequestMsg.cs b/SnaffCore/ActiveDirectory/Management/IMDA/ADPutRequestMsg.cs new file mode 100644 index 00000000..d6137b79 --- /dev/null +++ b/SnaffCore/ActiveDirectory/Management/IMDA/ADPutRequestMsg.cs @@ -0,0 +1,96 @@ +using System; +using System.Collections.Generic; +using System.DirectoryServices.Protocols; +using System.Xml; + +namespace Microsoft.ActiveDirectory.Management.IMDA +{ + // Token: 0x0200030A RID: 778 + internal class ADPutRequestMsg : AdimdaRequestMsg + { + // Token: 0x06001ACA RID: 6858 RVA: 0x00052E99 File Offset: 0x00051099 + private ADPutRequestMsg(string instance, string objectReference, IList controls) + : base(instance, objectReference) + { + this._controls = controls; + } + + // Token: 0x06001ACB RID: 6859 RVA: 0x00052EAA File Offset: 0x000510AA + public ADPutRequestMsg(string instance, string objectReference, IList controls, IList attributeModifications) + : this(instance, objectReference, controls) + { + this._attributeMods = attributeModifications; + } + + // Token: 0x06001ACC RID: 6860 RVA: 0x00052EBD File Offset: 0x000510BD + public ADPutRequestMsg(string instance, string objectReference, IList controls, string relativeDistinguishedName) + : this(instance, objectReference, controls) + { + this._relativeDistinguishedName = relativeDistinguishedName; + } + + // Token: 0x06001ACD RID: 6861 RVA: 0x00052ED0 File Offset: 0x000510D0 + public ADPutRequestMsg(string instance, string objectReference, IList controls, string relativeDistinguishedName, string parent) + : this(instance, objectReference, controls) + { + this._relativeDistinguishedName = relativeDistinguishedName; + this._parent = parent; + } + + // Token: 0x06001ACE RID: 6862 RVA: 0x00052EEB File Offset: 0x000510EB + public ADPutRequestMsg(string instance, string objectReference, IList controls, string relativeDistinguishedName, string parent, IList attributeModifications) + : this(instance, objectReference, controls) + { + this._relativeDistinguishedName = relativeDistinguishedName; + this._parent = parent; + this._attributeMods = attributeModifications; + } + + // Token: 0x17000916 RID: 2326 + // (get) Token: 0x06001ACF RID: 6863 RVA: 0x00052F0E File Offset: 0x0005110E + public override string Action + { + get + { + return "http://schemas.xmlsoap.org/ws/2004/09/transfer/Put"; + } + } + + // Token: 0x06001AD0 RID: 6864 RVA: 0x00052F18 File Offset: 0x00051118 + protected override void OnWriteBodyContents(XmlDictionaryWriter writer) + { + base.OnWriteBodyContents(writer); + writer.WriteStartElement("ModifyRequest", "http://schemas.microsoft.com/2006/11/IdentityManagement/DirectoryAccess"); + writer.WriteAttributeString("Dialect", "http://schemas.microsoft.com/2008/1/ActiveDirectory/Dialect/XPath-Level-1"); + if (this._attributeMods != null) + { + foreach (DirectoryAttributeModification directoryAttributeModification in this._attributeMods) + { + AttributeTypeAndValueSerializer.Serialize(writer, directoryAttributeModification); + } + } + if (this._parent != null) + { + AttributeTypeAndValueSerializer.Serialize(writer, ChangeOperation.Replace, "http://schemas.microsoft.com/2008/1/ActiveDirectory", "container-hierarchy-parent", this._parent); + } + if (this._relativeDistinguishedName != null) + { + AttributeTypeAndValueSerializer.Serialize(writer, ChangeOperation.Replace, "http://schemas.microsoft.com/2008/1/ActiveDirectory", "relativeDistinguishedName", this._relativeDistinguishedName); + } + DirectoryControlSerializer.Serialize(writer, this._controls); + writer.WriteEndElement(); + } + + // Token: 0x04000C7F RID: 3199 + private IList _controls; + + // Token: 0x04000C80 RID: 3200 + private IList _attributeMods; + + // Token: 0x04000C81 RID: 3201 + private string _relativeDistinguishedName; + + // Token: 0x04000C82 RID: 3202 + private string _parent; + } +} diff --git a/SnaffCore/ActiveDirectory/Management/LdapOptionConstants.cs b/SnaffCore/ActiveDirectory/Management/LdapOptionConstants.cs new file mode 100644 index 00000000..3c31d9a6 --- /dev/null +++ b/SnaffCore/ActiveDirectory/Management/LdapOptionConstants.cs @@ -0,0 +1,59 @@ +using System; +using System.Text.RegularExpressions; + +namespace Microsoft.ActiveDirectory.Management +{ + // Token: 0x02000057 RID: 87 + internal class LdapOptionConstants + { + // Token: 0x060001A5 RID: 421 RVA: 0x000032F0 File Offset: 0x000014F0 + private LdapOptionConstants() + { + } + + // Token: 0x04000213 RID: 531 + internal static string LdapOptionSeperator = ";"; + + // Token: 0x04000214 RID: 532 + internal static string LowRangeGroup = "LOWRANGE"; + + // Token: 0x04000215 RID: 533 + internal static string HiRangeGroup = "HIRANGE"; + + // Token: 0x04000216 RID: 534 + internal static string RangeOptionText = "Range="; + + // Token: 0x04000217 RID: 535 + internal static string RangeValueSeperator = "-"; + + // Token: 0x04000218 RID: 536 + internal static string RangeOptionFormatString = string.Concat(new string[] + { + "{0}", + LdapOptionConstants.LdapOptionSeperator, + LdapOptionConstants.RangeOptionText, + "{1}", + LdapOptionConstants.RangeValueSeperator, + "{2}" + }); + + // Token: 0x04000219 RID: 537 + internal static Regex RangeOptionRegex = new Regex(string.Concat(new string[] + { + LdapOptionConstants.RangeOptionText, + "(?<", + LdapOptionConstants.LowRangeGroup, + ">[0-9]*)", + LdapOptionConstants.RangeValueSeperator, + "(?<", + LdapOptionConstants.HiRangeGroup, + ">[0-9]*|\\*)$" + }), RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.RightToLeft | RegexOptions.CultureInvariant); + + // Token: 0x0400021A RID: 538 + internal static int LowRangeIndex = LdapOptionConstants.RangeOptionRegex.GroupNumberFromName(LdapOptionConstants.LowRangeGroup); + + // Token: 0x0400021B RID: 539 + internal static int HighRangeIndex = LdapOptionConstants.RangeOptionRegex.GroupNumberFromName(LdapOptionConstants.HiRangeGroup); + } +} diff --git a/SnaffCore/ActiveDirectory/Management/StringResources.cs b/SnaffCore/ActiveDirectory/Management/StringResources.cs new file mode 100644 index 00000000..17ad3ba6 --- /dev/null +++ b/SnaffCore/ActiveDirectory/Management/StringResources.cs @@ -0,0 +1,982 @@ +using System; +using System.Globalization; +using System.Reflection; +using System.Resources; + +namespace Microsoft.ActiveDirectory +{ + // Token: 0x0200003C RID: 60 + internal class StringResources + { + // Token: 0x0600012B RID: 299 RVA: 0x00002D74 File Offset: 0x00000F74 + static StringResources() + { + ResourceManager resourceManager = new ResourceManager("Microsoft.ActiveDirectory.Management", Assembly.GetExecutingAssembly()); + Type typeFromHandle = typeof(StringResources); + foreach (MemberInfo memberInfo in typeFromHandle.GetMembers(BindingFlags.Static | BindingFlags.Public)) + { + typeFromHandle.InvokeMember(memberInfo.Name, BindingFlags.SetField, null, null, new object[] { resourceManager.GetString(memberInfo.Name, CultureInfo.CurrentUICulture) }, CultureInfo.CurrentCulture); + } + } + + // Token: 0x0400009E RID: 158 + public static string NoNegativeTime; + + // Token: 0x0400009F RID: 159 + public static string TimeoutError; + + // Token: 0x040000A0 RID: 160 + public static string NoNegativeSizeLimit; + + // Token: 0x040000A1 RID: 161 + public static string NoNegativePageSize; + + // Token: 0x040000A2 RID: 162 + public static string SearchSizeLimitExceeded; + + // Token: 0x040000A3 RID: 163 + public static string ExceedMax; + + // Token: 0x040000A4 RID: 164 + public static string NotSupportedSessionOption; + + // Token: 0x040000A5 RID: 165 + public static string InvalidType; + + // Token: 0x040000A6 RID: 166 + public static string InvalidYear; + + // Token: 0x040000A7 RID: 167 + public static string EmptyStringParameter; + + // Token: 0x040000A8 RID: 168 + public static string ServerDown; + + // Token: 0x040000A9 RID: 169 + public static string DefaultServerNotFound; + + // Token: 0x040000AA RID: 170 + public static string DefaultADWSServerNotFound; + + // Token: 0x040000AB RID: 171 + public static string ServerOutOfMemory; + + // Token: 0x040000AC RID: 172 + public static string NoMixedType; + + // Token: 0x040000AD RID: 173 + public static string ForestIdDoesNotMatch; + + // Token: 0x040000AE RID: 174 + public static string NotSupportedGCPort; + + // Token: 0x040000AF RID: 175 + public static string InvalidUriFormat; + + // Token: 0x040000B0 RID: 176 + public static string InvalidPartitionMustBelongToValidSet; + + // Token: 0x040000B1 RID: 177 + public static string InvalidDNMustBelongToValidPartitionSet; + + // Token: 0x040000B2 RID: 178 + public static string ADFilterOperatorNotSupported; + + // Token: 0x040000B3 RID: 179 + public static string ADFilterParsingErrorMessage; + + // Token: 0x040000B4 RID: 180 + public static string ADFilterVariableNotDefinedMessage; + + // Token: 0x040000B5 RID: 181 + public static string ADFilterExprListLessThanTwo; + + // Token: 0x040000B6 RID: 182 + public static string ADFilterPropertyNotFoundInObject; + + // Token: 0x040000B7 RID: 183 + public static string ADWSXmlParserInvalidelement; + + // Token: 0x040000B8 RID: 184 + public static string ADWSXmlParserUnexpectedElement; + + // Token: 0x040000B9 RID: 185 + public static string ADWSXmlParserInvalidAttribute; + + // Token: 0x040000BA RID: 186 + public static string ADWSXmlParserMandatoryHeaderNotUnderstood; + + // Token: 0x040000BB RID: 187 + public static string ADWSXmlParserEmptyMessageReceived; + + // Token: 0x040000BC RID: 188 + public static string ADWSXmlParserInvalidActionForMessage; + + // Token: 0x040000BD RID: 189 + public static string ADProviderSetItemNotSupported; + + // Token: 0x040000BE RID: 190 + public static string ADProviderClearItemNotSupported; + + // Token: 0x040000BF RID: 191 + public static string ADProviderExecuteItemNotSupported; + + // Token: 0x040000C0 RID: 192 + public static string ADProviderCopyItemNotSupported; + + // Token: 0x040000C1 RID: 193 + public static string ADProviderPathNotFound; + + // Token: 0x040000C2 RID: 194 + public static string ADProviderPropertiesNotSpecified; + + // Token: 0x040000C3 RID: 195 + public static string ADProviderPropertyValueCannotBeNull; + + // Token: 0x040000C4 RID: 196 + public static string ADProviderPropertiesToClearNotSpecified; + + // Token: 0x040000C5 RID: 197 + public static string ADProviderSDNotSet; + + // Token: 0x040000C6 RID: 198 + public static string ADProviderGCInvalidForADLDS; + + // Token: 0x040000C7 RID: 199 + public static string ADProviderGCInvalidWithAppendedPort; + + // Token: 0x040000C8 RID: 200 + public static string ADProviderUnableToGetPartition; + + // Token: 0x040000C9 RID: 201 + public static string ADProviderOperationNotSupportedForRootDSE; + + // Token: 0x040000CA RID: 202 + public static string ADProviderOperationNotSupportedForRootDSEUnlessGC; + + // Token: 0x040000CB RID: 203 + public static string ADProviderInvalidPropertyName; + + // Token: 0x040000CC RID: 204 + public static string ADProviderUnableToReadProperty; + + // Token: 0x040000CD RID: 205 + public static string ADProviderErrorInitializingDefaultDrive; + + // Token: 0x040000CE RID: 206 + public static string ProviderUtilInvalidDrivePath; + + // Token: 0x040000CF RID: 207 + public static string TranslateNameError; + + // Token: 0x040000D0 RID: 208 + public static string LoadingDriveProgressMessage; + + // Token: 0x040000D1 RID: 209 + public static string UnspecifiedError; + + // Token: 0x040000D2 RID: 210 + public static string OperationSuccessful; + + // Token: 0x040000D3 RID: 211 + public static string NoSchemaClassInSchemaCache; + + // Token: 0x040000D4 RID: 212 + public static string SessionRequired; + + // Token: 0x040000D5 RID: 213 + public static string CustomAttributeCollision; + + // Token: 0x040000D6 RID: 214 + public static string MultipleKeywords; + + // Token: 0x040000D7 RID: 215 + public static string InvalidParameterValue; + + // Token: 0x040000D8 RID: 216 + public static string InvalidHashtableKey; + + // Token: 0x040000D9 RID: 217 + public static string InvalidNullValue; + + // Token: 0x040000DA RID: 218 + public static string InvalidEmptyCollection; + + // Token: 0x040000DB RID: 219 + public static string InvalidNullInCollection; + + // Token: 0x040000DC RID: 220 + public static string InvalidParameterType; + + // Token: 0x040000DD RID: 221 + public static string ParameterRequired; + + // Token: 0x040000DE RID: 222 + public static string ParameterRequiredMultiple; + + // Token: 0x040000DF RID: 223 + public static string ParameterRequiredOnlyOne; + + // Token: 0x040000E0 RID: 224 + public static string ObjectNotFound; + + // Token: 0x040000E1 RID: 225 + public static string InstanceMustBeOfType; + + // Token: 0x040000E2 RID: 226 + public static string InvalidObjectClass; + + // Token: 0x040000E3 RID: 227 + public static string InvalidObjectClasses; + + // Token: 0x040000E4 RID: 228 + public static string MultipleMatches; + + // Token: 0x040000E5 RID: 229 + public static string InvalidHashtableKeyType; + + // Token: 0x040000E6 RID: 230 + public static string InvalidTypeInCollection; + + // Token: 0x040000E7 RID: 231 + public static string ObjectTypeNotEqualToExpectedType; + + // Token: 0x040000E8 RID: 232 + public static string DistinguishedNameCannotBeNull; + + // Token: 0x040000E9 RID: 233 + public static string FSMORoleNotFoundInDomain; + + // Token: 0x040000EA RID: 234 + public static string FSMORoleNotFoundInForest; + + // Token: 0x040000EB RID: 235 + public static string SearchConverterRHSNotDataNode; + + // Token: 0x040000EC RID: 236 + public static string SearchConverterNotBinaryNode; + + // Token: 0x040000ED RID: 237 + public static string SearchConverterSupportedOperatorListErrorMessage; + + // Token: 0x040000EE RID: 238 + public static string SearchConverterInvalidValue; + + // Token: 0x040000EF RID: 239 + public static string SearchConverterUnrecognizedObjectType; + + // Token: 0x040000F0 RID: 240 + public static string SearchConverterIdentityAttributeNotSet; + + // Token: 0x040000F1 RID: 241 + public static string SearchConverterRHSInvalidType; + + // Token: 0x040000F2 RID: 242 + public static string SearchConverterAttributeNotSupported; + + // Token: 0x040000F3 RID: 243 + public static string SearchConverterUseSearchADAccount; + + // Token: 0x040000F4 RID: 244 + public static string SearchConverterRHSNotMatchEnumValue; + + // Token: 0x040000F5 RID: 245 + public static string AttributeConverterUnrecognizedObjectType; + + // Token: 0x040000F6 RID: 246 + public static string InsufficientPermissionsToProtectObject; + + // Token: 0x040000F7 RID: 247 + public static string InsufficientPermissionsToProtectObjectParent; + + // Token: 0x040000F8 RID: 248 + public static string CannotResolveIPAddressToHostName; + + // Token: 0x040000F9 RID: 249 + public static string WarningSamAccountNameClauseLacksDollarSign; + + // Token: 0x040000FA RID: 250 + public static string FailedAddingMembersToGroup; + + // Token: 0x040000FB RID: 251 + public static string FailedAddingMembersToOneOrMoreGroup; + + // Token: 0x040000FC RID: 252 + public static string FailedRemovingMembersFromGroup; + + // Token: 0x040000FD RID: 253 + public static string FailedRemovingMembersFromOneOrMoreGroup; + + // Token: 0x040000FE RID: 254 + public static string PasswordRestrictionErrorMessage; + + // Token: 0x040000FF RID: 255 + public static string ChangePasswordErrorMessage; + + // Token: 0x04000100 RID: 256 + public static string UserPressedBreakDuringPasswordEntry; + + // Token: 0x04000101 RID: 257 + public static string PromptForCurrentPassword; + + // Token: 0x04000102 RID: 258 + public static string PromptForNewPassword; + + // Token: 0x04000103 RID: 259 + public static string PromptForRepeatPassword; + + // Token: 0x04000104 RID: 260 + public static string PasswordsDidNotMatch; + + // Token: 0x04000105 RID: 261 + public static string PasswordChangeSuccessful; + + // Token: 0x04000106 RID: 262 + public static string MethodNotSupportedForObjectType; + + // Token: 0x04000107 RID: 263 + public static string UnsupportedObjectClass; + + // Token: 0x04000108 RID: 264 + public static string AttributeNotFoundOnObject; + + // Token: 0x04000109 RID: 265 + public static string WarningPolicyUsageNotAccurateOnRODC; + + // Token: 0x0400010A RID: 266 + public static string WarningResultantPRPNotAccurateOnRODC; + + // Token: 0x0400010B RID: 267 + public static string ErrorResultantPRPSpecifyWindows2008OrAbove; + + // Token: 0x0400010C RID: 268 + public static string UnsupportedOptionSpecified; + + // Token: 0x0400010D RID: 269 + public static string MoveOperationMasterRoleCaption; + + // Token: 0x0400010E RID: 270 + public static string MoveOperationMasterRoleWarning; + + // Token: 0x0400010F RID: 271 + public static string MoveOperationMasterRoleDescription; + + // Token: 0x04000110 RID: 272 + public static string MoveOperationMasterRoleNotApplicableForADLDS; + + // Token: 0x04000111 RID: 273 + public static string DuplicateValuesSpecified; + + // Token: 0x04000112 RID: 274 + public static string CouldNotDetermineLoggedOnUserDomain; + + // Token: 0x04000113 RID: 275 + public static string CouldNotDetermineLocalComputerDomain; + + // Token: 0x04000114 RID: 276 + public static string RequiresDomainCredentials; + + // Token: 0x04000115 RID: 277 + public static string UseSetADDomainMode; + + // Token: 0x04000116 RID: 278 + public static string UseSetADForestMode; + + // Token: 0x04000117 RID: 279 + public static string ADInvalidQuantizationDays; + + // Token: 0x04000118 RID: 280 + public static string ADInvalidQuantizationHours; + + // Token: 0x04000119 RID: 281 + public static string ADInvalidQuantizationMinutes; + + // Token: 0x0400011A RID: 282 + public static string ADInvalidQuantizationFifteenMinuteIntervals; + + // Token: 0x0400011B RID: 283 + public static string CannotInstallServiceAccount; + + // Token: 0x0400011C RID: 284 + public static string ServiceAccountIsNotInstalled; + + // Token: 0x0400011D RID: 285 + public static string CannotResetPasswordOfServiceAccount; + + // Token: 0x0400011E RID: 286 + public static string CannotUninstallServiceAccount; + + // Token: 0x0400011F RID: 287 + public static string CannotTestServiceAccount; + + // Token: 0x04000120 RID: 288 + public static string NetAddServiceAccountFailed; + + // Token: 0x04000121 RID: 289 + public static string CannotReachHostingDC; + + // Token: 0x04000122 RID: 290 + public static string OtherBackLinkDescription; + + // Token: 0x04000123 RID: 291 + public static string OtherBackLinkCaption; + + // Token: 0x04000124 RID: 292 + public static string ServiceAccountNameLengthInvalid; + + // Token: 0x04000125 RID: 293 + public static string AcctChangePwdNotWorksWhenPwdNotExpires; + + // Token: 0x04000126 RID: 294 + public static string AddADPrincipalGroupMembershipShouldProcessCaption; + + // Token: 0x04000127 RID: 295 + public static string AddADPrincipalGroupMembershipShouldProcessWarning; + + // Token: 0x04000128 RID: 296 + public static string AddADPrincipalGroupMembershipShouldProcessDescription; + + // Token: 0x04000129 RID: 297 + public static string RemoveADPrincipalGroupMembershipShouldProcessCaption; + + // Token: 0x0400012A RID: 298 + public static string RemoveADPrincipalGroupMembershipShouldProcessWarning; + + // Token: 0x0400012B RID: 299 + public static string RemoveADPrincipalGroupMembershipShouldProcessDescription; + + // Token: 0x0400012C RID: 300 + public static string ParameterValueNotSearchResult; + + // Token: 0x0400012D RID: 301 + public static string GetGroupMembershipResourceContextParameterCheck; + + // Token: 0x0400012E RID: 302 + public static string IdentityResolutionPartitionRequired; + + // Token: 0x0400012F RID: 303 + public static string IdentityInExtendedAttributeCannotBeResolved; + + // Token: 0x04000130 RID: 304 + public static string IdentityNotFound; + + // Token: 0x04000131 RID: 305 + public static string IdentityInWrongPartition; + + // Token: 0x04000132 RID: 306 + public static string DirectoryServerNotFound; + + // Token: 0x04000133 RID: 307 + public static string EnablingIsIrreversible; + + // Token: 0x04000134 RID: 308 + public static string CouldNotSetForestMode; + + // Token: 0x04000135 RID: 309 + public static string CouldNotFindForestIdentity; + + // Token: 0x04000136 RID: 310 + public static string ConnectedToWrongForest; + + // Token: 0x04000137 RID: 311 + public static string EmptySearchBaseNotSupported; + + // Token: 0x04000138 RID: 312 + public static string PromptForRemove; + + // Token: 0x04000139 RID: 313 + public static string PromptForRecursiveRemove; + + // Token: 0x0400013A RID: 314 + public static string PerformingRecursiveRemove; + + // Token: 0x0400013B RID: 315 + public static string ConfigSetNotFound; + + // Token: 0x0400013C RID: 316 + public static string ADInvalidAttributeValueCount; + + // Token: 0x0400013D RID: 317 + public static string ServerContainerNotEmpty; + + // Token: 0x0400013E RID: 318 + public static string InvalidClaimValueType; + + // Token: 0x0400013F RID: 319 + public static string InvalidPossibleValuesXml; + + // Token: 0x04000140 RID: 320 + public static string NextVersionPossibleValuesXml; + + // Token: 0x04000141 RID: 321 + public static string CannotOverwriteNextVersionXml; + + // Token: 0x04000142 RID: 322 + public static string SPCTNoSourceWarning; + + // Token: 0x04000143 RID: 323 + public static string SPCTBothSourceWarning; + + // Token: 0x04000144 RID: 324 + public static string SPCTBothSourceOIDPossibleValuesWarning; + + // Token: 0x04000145 RID: 325 + public static string CTBothPossibleValuesShareValueWarning; + + // Token: 0x04000146 RID: 326 + public static string SPCTInvalidAppliesToClassWarning; + + // Token: 0x04000147 RID: 327 + public static string CTParameterValidationFailure; + + // Token: 0x04000148 RID: 328 + public static string SPCTInvalidSourceAttributeName; + + // Token: 0x04000149 RID: 329 + public static string SPCTBlockedSourceAttribute; + + // Token: 0x0400014A RID: 330 + public static string SPCTNonREPLSourceAttrError; + + // Token: 0x0400014B RID: 331 + public static string SPCTRODCFilteredSourceAttr; + + // Token: 0x0400014C RID: 332 + public static string SPCTDefuctSourceAttr; + + // Token: 0x0400014D RID: 333 + public static string SPCTInvalidAttributeSyntax; + + // Token: 0x0400014E RID: 334 + public static string CTSourceOIDValueTypeError; + + // Token: 0x0400014F RID: 335 + public static string CTSourceAttributeValueTypeError; + + // Token: 0x04000150 RID: 336 + public static string RCTNoResourcePropertyValueTypeError; + + // Token: 0x04000151 RID: 337 + public static string InvalidValueTypeForPossibleValueXml; + + // Token: 0x04000152 RID: 338 + public static string SPCTSourceAttributeLdapDisplayNameError; + + // Token: 0x04000153 RID: 339 + public static string SPCTAttributeNotFoundInSchemaClass; + + // Token: 0x04000154 RID: 340 + public static string CAPIDCreationFailure; + + // Token: 0x04000155 RID: 341 + public static string CAPMemberMaximumExceeded; + + // Token: 0x04000156 RID: 342 + public static string SPCTInvalidSourceAttribute; + + // Token: 0x04000157 RID: 343 + public static string RCTSuggestedValueNotPresentError; + + // Token: 0x04000158 RID: 344 + public static string RCTSuggestedValuePresentError; + + // Token: 0x04000159 RID: 345 + public static string ResourcePropertySharesValueWithValueTypeError; + + // Token: 0x0400015A RID: 346 + public static string SuggestedValueNotUniqueError; + + // Token: 0x0400015B RID: 347 + public static string ADTrustNoDirectionAndPolicyError; + + // Token: 0x0400015C RID: 348 + public static string ClaimPolicyXmlWarning; + + // Token: 0x0400015D RID: 349 + public static string ClaimPolicyXmlNodeError; + + // Token: 0x0400015E RID: 350 + public static string ServerParameterNotSupported; + + // Token: 0x0400015F RID: 351 + public static string XmlFormattingError; + + // Token: 0x04000160 RID: 352 + public static string RuleValidationFailure; + + // Token: 0x04000161 RID: 353 + public static string ResouceConditionValidationFailed; + + // Token: 0x04000162 RID: 354 + public static string SDDLValidationFailed; + + // Token: 0x04000163 RID: 355 + public static string DisplayNameNotUniqueError; + + // Token: 0x04000164 RID: 356 + public static string RemoveClaimTypeSharesValueWithError; + + // Token: 0x04000165 RID: 357 + public static string SharesValueWithIdentityError; + + // Token: 0x04000166 RID: 358 + public static string ServerTargetParameterNotSpecified; + + // Token: 0x04000167 RID: 359 + public static string TargetParameterHM; + + // Token: 0x04000168 RID: 360 + public static string ClaimIDValidationError; + + // Token: 0x04000169 RID: 361 + public static string ResourceIDValidationError; + + // Token: 0x0400016A RID: 362 + public static string ClaimTypeRestrictValueError; + + // Token: 0x0400016B RID: 363 + public static string RemoveCmdletBacklinkWarning; + + // Token: 0x0400016C RID: 364 + public static string TicksToMinsRoundOffWarning; + + // Token: 0x0400016D RID: 365 + public static string DefaultAuthenticationPolicyExpressionTitle; + + // Token: 0x0400016E RID: 366 + public static string DefaultAuthenticationPolicyExpressionMessage; + + // Token: 0x0400016F RID: 367 + public static string InitializeClaimDictionaryError; + + // Token: 0x04000170 RID: 368 + public static string EditConditionalAceClaimsError; + + // Token: 0x04000171 RID: 369 + public static string DomainModeDeprecatedWarning; + + // Token: 0x04000172 RID: 370 + public static string ForestModeDeprecatedWarning; + + // Token: 0x04000173 RID: 371 + public static string PropertyIsReadonly; + + // Token: 0x04000174 RID: 372 + public static string NoConversionExists; + + // Token: 0x04000175 RID: 373 + public static string TypeConversionError; + + // Token: 0x04000176 RID: 374 + public static string TypeAdapterForADEntityOnly; + + // Token: 0x04000177 RID: 375 + public static string EnumConversionError; + + // Token: 0x04000178 RID: 376 + public static string ServerActionNotSupportedFault; + + // Token: 0x04000179 RID: 377 + public static string ServerCannotProcessFilter; + + // Token: 0x0400017A RID: 378 + public static string ServerEncodingLimit; + + // Token: 0x0400017B RID: 379 + public static string ServerEnumerationContextLimitExceeded; + + // Token: 0x0400017C RID: 380 + public static string ServerFilterDialectRequestedUnavailable; + + // Token: 0x0400017D RID: 381 + public static string ServerFragmentDialectNotSupported; + + // Token: 0x0400017E RID: 382 + public static string ServerInvalidEnumerationContext; + + // Token: 0x0400017F RID: 383 + public static string ServerInvalidExpirationTime; + + // Token: 0x04000180 RID: 384 + public static string ServerSchemaValidationError; + + // Token: 0x04000181 RID: 385 + public static string ServerUnsupportedSelectOrSortDialectFault; + + // Token: 0x04000182 RID: 386 + public static string ServerAnonymousNotAllowed; + + // Token: 0x04000183 RID: 387 + public static string ServerInvalidInstance; + + // Token: 0x04000184 RID: 388 + public static string ServerMultipleMatchingSecurityPrincipals; + + // Token: 0x04000185 RID: 389 + public static string ServerNoMatchingSecurityPrincipal; + + // Token: 0x04000186 RID: 390 + public static string InvalidProperty; + + // Token: 0x04000187 RID: 391 + public static string InvalidFilter; + + // Token: 0x04000188 RID: 392 + public static string AsqResponseError; + + // Token: 0x04000189 RID: 393 + public static string ADAccountRPRPIdentityHM; + + // Token: 0x0400018A RID: 394 + public static string ADAccountRPRPDomainControllerHM; + + // Token: 0x0400018B RID: 395 + public static string ADDCPRPUIdentityHM; + + // Token: 0x0400018C RID: 396 + public static string ADObjectFilterHM; + + // Token: 0x0400018D RID: 397 + public static string ADOUFilterHM; + + // Token: 0x0400018E RID: 398 + public static string ADComputerServiceAccountIdentityHM; + + // Token: 0x0400018F RID: 399 + public static string ADFineGrainedPPFilterHM; + + // Token: 0x04000190 RID: 400 + public static string ADFGPPSubjectIdentityHM; + + // Token: 0x04000191 RID: 401 + public static string ADGroupFilterHM; + + // Token: 0x04000192 RID: 402 + public static string ADGroupMemberIdentityHM; + + // Token: 0x04000193 RID: 403 + public static string ADDCPRPIdentityHM; + + // Token: 0x04000194 RID: 404 + public static string ADPrincipalGMIdentityHM; + + // Token: 0x04000195 RID: 405 + public static string ADOFFilterHM; + + // Token: 0x04000196 RID: 406 + public static string ADUserFilterHM; + + // Token: 0x04000197 RID: 407 + public static string ADAccountAuthGroupIdentityHM; + + // Token: 0x04000198 RID: 408 + public static string ADUserResultantPPIdentityHM; + + // Token: 0x04000199 RID: 409 + public static string ADServiceAccountFilterHM; + + // Token: 0x0400019A RID: 410 + public static string ADComputerFilterHM; + + // Token: 0x0400019B RID: 411 + public static string NullOrEmptyIdentityPropertyArgument; + + // Token: 0x0400019C RID: 412 + public static string DelegatePipelineEmptyError; + + // Token: 0x0400019D RID: 413 + public static string DelegatePipelineUnsupportedTypeError; + + // Token: 0x0400019E RID: 414 + public static string DelegatePipelineMulticastDelegatesNotAllowedError; + + // Token: 0x0400019F RID: 415 + public static string DelegatePipelineReferenceDelegateNotFoundError; + + // Token: 0x040001A0 RID: 416 + public static string ValidateRangeLessThanMinValue; + + // Token: 0x040001A1 RID: 417 + public static string ValidateRangeGreaterThanMaxValue; + + // Token: 0x040001A2 RID: 418 + public static string ObjectToReplicateNotFoundOnSource; + + // Token: 0x040001A3 RID: 419 + public static string SourceServerDown; + + // Token: 0x040001A4 RID: 420 + public static string PasswordOnlySwitchAllowedOnlyOnRODC; + + // Token: 0x040001A5 RID: 421 + public static string DestinationDoesNotTargetDirectoryServer; + + // Token: 0x040001A6 RID: 422 + public static string SourceDoesNotTargetDirectoryServer; + + // Token: 0x040001A7 RID: 423 + public static string DestinationServerDown; + + // Token: 0x040001A8 RID: 424 + public static string SourceServerObjNotFoundOrObjToReplicateNotFound; + + // Token: 0x040001A9 RID: 425 + public static string DestinationServerDoesNotSupportSynchronizingObject; + + // Token: 0x040001AA RID: 426 + public static string SiteLinkAndSiteLinkBridgeDoNotShareSameTransportType; + + // Token: 0x040001AB RID: 427 + public static string NoMatchingResultsForTarget; + + // Token: 0x040001AC RID: 428 + public static string OnlySearchResultsSupported; + + // Token: 0x040001AD RID: 429 + public static string UnsupportedParameterType; + + // Token: 0x040001AE RID: 430 + public static string ServerDoesNotHaveFriendlyPartition; + + // Token: 0x040001AF RID: 431 + public static string ServerIsNotDirectoryServer; + + // Token: 0x040001B0 RID: 432 + public static string UnableToFindSiteForLocalMachine; + + // Token: 0x040001B1 RID: 433 + public static string MsaStandloneNotLinked; + + // Token: 0x040001B2 RID: 434 + public static string MsaStandaloneLinkedToAlternateComputer; + + // Token: 0x040001B3 RID: 435 + public static string MsaDoesNotExist; + + // Token: 0x040001B4 RID: 436 + public static string MsaNotServiceAccount; + + // Token: 0x040001B5 RID: 437 + public static string InvalidACEInSecDesc; + + // Token: 0x040001B6 RID: 438 + public static string ADDCCloningExcludedApplicationListErrorMessage; + + // Token: 0x040001B7 RID: 439 + public static string ADDCCloningExcludedApplicationListCustomerAllowListFileNameMessage; + + // Token: 0x040001B8 RID: 440 + public static string ADDCCloningExcludedApplicationListNoCustomerAllowListFileMessage; + + // Token: 0x040001B9 RID: 441 + public static string ADDCCloningExcludedApplicationListInvalidPath; + + // Token: 0x040001BA RID: 442 + public static string ADDCCloningExcludedApplicationListNoAppsFound; + + // Token: 0x040001BB RID: 443 + public static string ADDCCloningExcludedApplicationListFilePriority; + + // Token: 0x040001BC RID: 444 + public static string ADDCCloningExcludedApplicationListPathPriority; + + // Token: 0x040001BD RID: 445 + public static string ADDCCloningExcludedApplicationListFileExists; + + // Token: 0x040001BE RID: 446 + public static string ADDCCloningExcludedApplicationListNewAllowList; + + // Token: 0x040001BF RID: 447 + public static string ADDCCloningExcludedApplicationListLocalMachineNotADCMessage; + + // Token: 0x040001C0 RID: 448 + public static string NewADDCCloneConfigFileLocatingWin8PDCMessage; + + // Token: 0x040001C1 RID: 449 + public static string NewADDCCloneConfigFileNoWin8PDCMessage; + + // Token: 0x040001C2 RID: 450 + public static string NewADDCCloneConfigFileFoundWin8PDCMessage; + + // Token: 0x040001C3 RID: 451 + public static string NewADDCCloneConfigFileCheckCloningPrivilegeMessage; + + // Token: 0x040001C4 RID: 452 + public static string NewADDCCloneConfigFileNoLocalDCMessage; + + // Token: 0x040001C5 RID: 453 + public static string NewADDCCloneConfigFileFoundLocalDCMessage; + + // Token: 0x040001C6 RID: 454 + public static string NewADDCCloneConfigFileNoLocalDCMembershipMessage; + + // Token: 0x040001C7 RID: 455 + public static string NewADDCCloneConfigFileNoCloningPrivilegeMessage; + + // Token: 0x040001C8 RID: 456 + public static string NewADDCCloneConfigFileFailQueryRootObject; + + // Token: 0x040001C9 RID: 457 + public static string NewADDCCloneConfigFileHasCloningPrivilegeMessage; + + // Token: 0x040001CA RID: 458 + public static string NewADDCCloneConfigFileTestWhiteListMessage; + + // Token: 0x040001CB RID: 459 + public static string NewADDCCloneConfigFileWhiteListCompleteMessage; + + // Token: 0x040001CC RID: 460 + public static string NewADDCCloneConfigFileWhiteListNotCompleteMessage; + + // Token: 0x040001CD RID: 461 + public static string NewADDCCloneConfigFileOfflineModeMessage; + + // Token: 0x040001CE RID: 462 + public static string NewADDCCloneConfigFileLocalModeMessage; + + // Token: 0x040001CF RID: 463 + public static string NewADDCCloneConfigFileGenerateFileMessage; + + // Token: 0x040001D0 RID: 464 + public static string NewADDCCloneConfigFileNoGenerateFileMessage; + + // Token: 0x040001D1 RID: 465 + public static string NewADDCCloneConfigFileGetDitLocationMessage; + + // Token: 0x040001D2 RID: 466 + public static string NewADDCCloneConfigFileNoDitLocationMessage; + + // Token: 0x040001D3 RID: 467 + public static string NewADDCCloneConfigFileGenerationMessage; + + // Token: 0x040001D4 RID: 468 + public static string NewADDCCloneConfigFileFullNameMessage; + + // Token: 0x040001D5 RID: 469 + public static string NewADDCCloneConfigFileGeneratingContentMessage; + + // Token: 0x040001D6 RID: 470 + public static string NewADDCCloneConfigFileGeneratedMessage; + + // Token: 0x040001D7 RID: 471 + public static string NewADDCCloneConfigFileExistingMessage; + + // Token: 0x040001D8 RID: 472 + public static string NewADDCCloneConfigFileNotExistingMessage; + + // Token: 0x040001D9 RID: 473 + public static string NewADDCCloneConfigFileFoundMessage; + + // Token: 0x040001DA RID: 474 + public static string NewADDCCloneConfigFileAtWrongLocationMessage; + + // Token: 0x040001DB RID: 475 + public static string NewADDCCloneConfigFileInvalidIpv4StaticMessage; + + // Token: 0x040001DC RID: 476 + public static string NewADDCCloneConfigFileMoreDnsMessage; + + // Token: 0x040001DD RID: 477 + public static string NewADDCCloneConfigFileLocalModeNoLocalDCMessage; + } +} diff --git a/SnaffCore/ActiveDirectory/Management/SyntheticAttributeOperation.cs b/SnaffCore/ActiveDirectory/Management/SyntheticAttributeOperation.cs new file mode 100644 index 00000000..89f0f56a --- /dev/null +++ b/SnaffCore/ActiveDirectory/Management/SyntheticAttributeOperation.cs @@ -0,0 +1,14 @@ +using System; + +namespace Microsoft.ActiveDirectory.Management +{ + // Token: 0x020000B5 RID: 181 + [Flags] + internal enum SyntheticAttributeOperation + { + // Token: 0x040004B9 RID: 1209 + Read = 1, + // Token: 0x040004BA RID: 1210 + Write = 2 + } +} diff --git a/SnaffCore/ActiveDirectory/Management/WSE/ADEnumerateLdapRequest.cs b/SnaffCore/ActiveDirectory/Management/WSE/ADEnumerateLdapRequest.cs new file mode 100644 index 00000000..57e7bf26 --- /dev/null +++ b/SnaffCore/ActiveDirectory/Management/WSE/ADEnumerateLdapRequest.cs @@ -0,0 +1,116 @@ +using System; +using System.Collections.Generic; +using System.Xml; + +namespace Microsoft.ActiveDirectory.Management.WSE +{ + // Token: 0x0200030C RID: 780 + internal class ADEnumerateLdapRequest : ADEnumerateRequest + { + // Token: 0x06001AD8 RID: 6872 RVA: 0x0005303C File Offset: 0x0005123C + public ADEnumerateLdapRequest(string instance) + : base(instance) + { + } + + // Token: 0x06001AD9 RID: 6873 RVA: 0x00053045 File Offset: 0x00051245 + public ADEnumerateLdapRequest(string instance, string filter, string searchBase, string searchScope) + : this(instance) + { + this.Filter = filter; + this.SearchBase = searchBase; + this.SearchScope = searchScope; + } + + // Token: 0x06001ADA RID: 6874 RVA: 0x00053064 File Offset: 0x00051264 + public ADEnumerateLdapRequest(string instance, string filter, string searchBase, string searchScope, IList attributes) + : base(instance, attributes) + { + this.Filter = filter; + this.SearchBase = searchBase; + this.SearchScope = searchScope; + } + + // Token: 0x1700091A RID: 2330 + // (get) Token: 0x06001ADB RID: 6875 RVA: 0x00053085 File Offset: 0x00051285 + protected override bool IsFilterPresent + { + get + { + return this._filter != null; + } + } + + // Token: 0x1700091B RID: 2331 + // (get) Token: 0x06001ADD RID: 6877 RVA: 0x00053099 File Offset: 0x00051299 + // (set) Token: 0x06001ADC RID: 6876 RVA: 0x00053090 File Offset: 0x00051290 + private string Filter + { + get + { + return this._filter; + } + set + { + this._filter = value; + } + } + + // Token: 0x1700091C RID: 2332 + // (get) Token: 0x06001ADF RID: 6879 RVA: 0x000530AA File Offset: 0x000512AA + // (set) Token: 0x06001ADE RID: 6878 RVA: 0x000530A1 File Offset: 0x000512A1 + private string SearchBase + { + get + { + return this._searchBase; + } + set + { + this._searchBase = value; + } + } + + // Token: 0x1700091D RID: 2333 + // (get) Token: 0x06001AE1 RID: 6881 RVA: 0x000530BB File Offset: 0x000512BB + // (set) Token: 0x06001AE0 RID: 6880 RVA: 0x000530B2 File Offset: 0x000512B2 + private string SearchScope + { + get + { + return this._searchScope; + } + set + { + this._searchScope = value; + } + } + + // Token: 0x06001AE2 RID: 6882 RVA: 0x000530C3 File Offset: 0x000512C3 + protected override void OnWriteStartFilterElement(XmlDictionaryWriter writer) + { + base.OnWriteStartFilterElement(writer); + writer.WriteAttributeString("Dialect", "http://schemas.microsoft.com/2008/1/ActiveDirectory/Dialect/LdapQuery"); + writer.WriteXmlnsAttribute("adlq", "http://schemas.microsoft.com/2008/1/ActiveDirectory/Dialect/LdapQuery"); + } + + // Token: 0x06001AE3 RID: 6883 RVA: 0x000530EC File Offset: 0x000512EC + protected override void OnWriteFilterElementContents(XmlDictionaryWriter writer) + { + writer.WriteStartElement("LdapQuery", "http://schemas.microsoft.com/2008/1/ActiveDirectory/Dialect/LdapQuery"); + writer.WriteElementString("Filter", "http://schemas.microsoft.com/2008/1/ActiveDirectory/Dialect/LdapQuery", this.Filter); + writer.WriteElementString("BaseObject", "http://schemas.microsoft.com/2008/1/ActiveDirectory/Dialect/LdapQuery", this.SearchBase); + writer.WriteElementString("Scope", "http://schemas.microsoft.com/2008/1/ActiveDirectory/Dialect/LdapQuery", this.SearchScope); + writer.WriteEndElement(); + } + + // Token: 0x04000C84 RID: 3204 + private string _filter; + + // Token: 0x04000C85 RID: 3205 + private string _searchBase; + + // Token: 0x04000C86 RID: 3206 + private string _searchScope; + } +} diff --git a/SnaffCore/ActiveDirectory/Management/WSE/ADEnumerateRequest.cs b/SnaffCore/ActiveDirectory/Management/WSE/ADEnumerateRequest.cs new file mode 100644 index 00000000..b9b637c9 --- /dev/null +++ b/SnaffCore/ActiveDirectory/Management/WSE/ADEnumerateRequest.cs @@ -0,0 +1,175 @@ +using System; +using System.Collections.Generic; +using System.DirectoryServices.Protocols; +using System.Xml; + +namespace Microsoft.ActiveDirectory.Management.WSE +{ + // Token: 0x0200030E RID: 782 + internal abstract class ADEnumerateRequest : AdwsRequestMsg + { + // Token: 0x06001AE7 RID: 6887 RVA: 0x0005316A File Offset: 0x0005136A + protected ADEnumerateRequest(string instance) + : base(instance) + { + } + + // Token: 0x06001AE8 RID: 6888 RVA: 0x00053173 File Offset: 0x00051373 + protected ADEnumerateRequest(string instance, IList attributes) + : this(instance) + { + this._attributes = attributes; + } + + // Token: 0x1700091E RID: 2334 + // (get) Token: 0x06001AE9 RID: 6889 + protected abstract bool IsFilterPresent { get; } + + // Token: 0x1700091F RID: 2335 + // (get) Token: 0x06001AEA RID: 6890 RVA: 0x00053183 File Offset: 0x00051383 + public override string Action + { + get + { + return "http://schemas.xmlsoap.org/ws/2004/09/enumeration/Enumerate"; + } + } + + // Token: 0x17000920 RID: 2336 + // (get) Token: 0x06001AEB RID: 6891 RVA: 0x0005318A File Offset: 0x0005138A + public virtual IList Attributes + { + get + { + if (this._attributes == null) + { + this._attributes = new List(0); + } + return this._attributes; + } + } + + // Token: 0x17000921 RID: 2337 + // (get) Token: 0x06001AED RID: 6893 RVA: 0x000531AF File Offset: 0x000513AF + // (set) Token: 0x06001AEC RID: 6892 RVA: 0x000531A6 File Offset: 0x000513A6 + public virtual SortKey SortKey + { + get + { + return this._sortKey; + } + set + { + this._sortKey = value; + } + } + + // Token: 0x17000922 RID: 2338 + // (get) Token: 0x06001AEF RID: 6895 RVA: 0x000531C0 File Offset: 0x000513C0 + // (set) Token: 0x06001AEE RID: 6894 RVA: 0x000531B7 File Offset: 0x000513B7 + protected DateTime? ExpirationDateTime + { + get + { + return this._expirationDateTime; + } + set + { + this._expirationDateTime = value; + } + } + + // Token: 0x17000923 RID: 2339 + // (get) Token: 0x06001AF1 RID: 6897 RVA: 0x000531D1 File Offset: 0x000513D1 + // (set) Token: 0x06001AF0 RID: 6896 RVA: 0x000531C8 File Offset: 0x000513C8 + protected TimeSpan? ExpirationTimeSpan + { + get + { + return this._expirationTimeSpan; + } + set + { + this._expirationTimeSpan = value; + } + } + + // Token: 0x06001AF2 RID: 6898 RVA: 0x000531DC File Offset: 0x000513DC + protected override void OnWriteBodyContents(XmlDictionaryWriter writer) + { + writer.WriteStartElement("Enumerate", "http://schemas.xmlsoap.org/ws/2004/09/enumeration"); + XmlUtility.SerializeExpires(writer, this._expirationDateTime, this._expirationTimeSpan); + if (this.IsFilterPresent) + { + this.OnWriteStartFilterElement(writer); + this.OnWriteFilterElementContents(writer); + writer.WriteEndElement(); + } + if (this._attributes != null && this._attributes.Count > 0) + { + writer.WriteStartElement("Selection", "http://schemas.microsoft.com/2008/1/ActiveDirectory"); + writer.WriteAttributeString("Dialect", "http://schemas.microsoft.com/2008/1/ActiveDirectory/Dialect/XPath-Level-1"); + XmlUtility.SerializeAttributeList(writer, "SelectionProperty", "http://schemas.microsoft.com/2008/1/ActiveDirectory", "ad", "addata", this._attributes); + writer.WriteEndElement(); + } + if (this._sortKey != null) + { + writer.WriteStartElement("Sorting", "http://schemas.microsoft.com/2008/1/ActiveDirectory"); + writer.WriteAttributeString("Dialect", "http://schemas.microsoft.com/2008/1/ActiveDirectory/Dialect/XPath-Level-1"); + writer.WriteStartElement("SortingProperty", "http://schemas.microsoft.com/2008/1/ActiveDirectory"); + if (this._sortKey.ReverseOrder) + { + writer.WriteAttributeString("Ascending", "false"); + } + string text = (AttributeNs.IsSynthetic(this._sortKey.AttributeName, SyntheticAttributeOperation.Read) ? "ad" : "addata"); + writer.WriteValue(XmlUtility.AddPrefix(text, this._sortKey.AttributeName)); + writer.WriteEndElement(); + writer.WriteEndElement(); + } + writer.WriteEndElement(); + } + + // Token: 0x06001AF3 RID: 6899 + protected abstract void OnWriteFilterElementContents(XmlDictionaryWriter writer); + + // Token: 0x06001AF4 RID: 6900 RVA: 0x00053324 File Offset: 0x00051524 + protected virtual void OnWriteStartFilterElement(XmlDictionaryWriter writer) + { + writer.WriteStartElement("Filter", "http://schemas.xmlsoap.org/ws/2004/09/enumeration"); + } + + // Token: 0x06001AF5 RID: 6901 RVA: 0x00053336 File Offset: 0x00051536 + protected override void OnWriteStartBody(XmlDictionaryWriter writer) + { + base.OnWriteStartBody(writer); + writer.WriteXmlnsAttribute("wsen", "http://schemas.xmlsoap.org/ws/2004/09/enumeration"); + writer.WriteXmlnsAttribute("adlq", "http://schemas.microsoft.com/2008/1/ActiveDirectory/Dialect/LdapQuery"); + } + + // Token: 0x06001AF6 RID: 6902 RVA: 0x0005335F File Offset: 0x0005155F + public virtual void SetContextExpiration(DateTime expiration) + { + this._expirationDateTime = new DateTime?(expiration); + this._expirationTimeSpan = null; + } + + // Token: 0x06001AF7 RID: 6903 RVA: 0x00053379 File Offset: 0x00051579 + public virtual void SetContextExpiration(TimeSpan expiration) + { + this._expirationTimeSpan = new TimeSpan?(expiration); + this._expirationDateTime = null; + } + + // Token: 0x04000C87 RID: 3207 + private TimeSpan? _expirationTimeSpan; + + // Token: 0x04000C88 RID: 3208 + private DateTime? _expirationDateTime; + + // Token: 0x04000C89 RID: 3209 + private IList _attributes; + + // Token: 0x04000C8A RID: 3210 + private SortKey _sortKey; + } +} diff --git a/SnaffCore/ActiveDirectory/Management/WSE/ADGetStatusRequest.cs b/SnaffCore/ActiveDirectory/Management/WSE/ADGetStatusRequest.cs new file mode 100644 index 00000000..f727bd70 --- /dev/null +++ b/SnaffCore/ActiveDirectory/Management/WSE/ADGetStatusRequest.cs @@ -0,0 +1,44 @@ +using System; +using System.Xml; + +namespace Microsoft.ActiveDirectory.Management.WSE +{ + // Token: 0x02000310 RID: 784 + internal class ADGetStatusRequest : AdwsRequestMsg + { + // Token: 0x06001AFE RID: 6910 RVA: 0x00053454 File Offset: 0x00051654 + public ADGetStatusRequest(string instance, string enumerationContext) + : base(instance) + { + this._enumerationContext = enumerationContext; + } + + // Token: 0x17000927 RID: 2343 + // (get) Token: 0x06001AFF RID: 6911 RVA: 0x00053464 File Offset: 0x00051664 + public override string Action + { + get + { + return "http://schemas.xmlsoap.org/ws/2004/09/enumeration/GetStatus"; + } + } + + // Token: 0x06001B00 RID: 6912 RVA: 0x0005346B File Offset: 0x0005166B + protected override void OnWriteStartBody(XmlDictionaryWriter writer) + { + base.OnWriteStartBody(writer); + writer.WriteXmlnsAttribute("wsen", "http://schemas.xmlsoap.org/ws/2004/09/enumeration"); + } + + // Token: 0x06001B01 RID: 6913 RVA: 0x00053484 File Offset: 0x00051684 + protected override void OnWriteBodyContents(XmlDictionaryWriter writer) + { + writer.WriteStartElement("GetStatus", "http://schemas.xmlsoap.org/ws/2004/09/enumeration"); + XmlUtility.SerializeEnumerationContext(writer, this._enumerationContext); + writer.WriteEndElement(); + } + + // Token: 0x04000C8E RID: 3214 + private string _enumerationContext; + } +} diff --git a/SnaffCore/ActiveDirectory/Management/WSE/ADPullRequest.cs b/SnaffCore/ActiveDirectory/Management/WSE/ADPullRequest.cs new file mode 100644 index 00000000..a19a4dbf --- /dev/null +++ b/SnaffCore/ActiveDirectory/Management/WSE/ADPullRequest.cs @@ -0,0 +1,141 @@ +using System; +using System.Collections.Generic; +using System.DirectoryServices.Protocols; +using System.Xml; + +namespace Microsoft.ActiveDirectory.Management.WSE +{ + // Token: 0x02000312 RID: 786 + internal class ADPullRequest : AdwsRequestMsg + { + // Token: 0x06001B09 RID: 6921 RVA: 0x0005354D File Offset: 0x0005174D + public ADPullRequest(string instance, string enumerationContext) + : base(instance) + { + if (string.IsNullOrEmpty(enumerationContext)) + { + throw new ArgumentNullException("enumerationContext"); + } + this._enumerationContext = enumerationContext; + } + + // Token: 0x06001B0A RID: 6922 RVA: 0x00053570 File Offset: 0x00051770 + public ADPullRequest(string instance, string enumerationContext, IList controls) + : this(instance, enumerationContext) + { + this._controls = controls; + } + + // Token: 0x06001B0B RID: 6923 RVA: 0x00053581 File Offset: 0x00051781 + public ADPullRequest(string instance, string enumerationContext, TimeSpan maxTime) + : this(instance, enumerationContext) + { + this._timeout = new TimeSpan?(maxTime); + this._enumerationContext = enumerationContext; + } + + // Token: 0x06001B0C RID: 6924 RVA: 0x0005359E File Offset: 0x0005179E + public ADPullRequest(string instance, string enumerationContext, TimeSpan maxTime, IList controls) + : this(instance, enumerationContext, maxTime) + { + this._controls = controls; + } + + // Token: 0x1700092B RID: 2347 + // (get) Token: 0x06001B0D RID: 6925 RVA: 0x000535B1 File Offset: 0x000517B1 + public override string Action + { + get + { + return "http://schemas.xmlsoap.org/ws/2004/09/enumeration/Pull"; + } + } + + // Token: 0x1700092C RID: 2348 + // (get) Token: 0x06001B0F RID: 6927 RVA: 0x000535ED File Offset: 0x000517ED + // (set) Token: 0x06001B0E RID: 6926 RVA: 0x000535B8 File Offset: 0x000517B8 + public virtual uint? MaxElements + { + get + { + return this._maxElements; + } + set + { + uint num = 0U; + uint? num2 = value; + if ((num == num2.GetValueOrDefault()) & (num2 != null)) + { + throw new ArgumentOutOfRangeException("value"); + } + this._maxElements = value; + } + } + + // Token: 0x1700092D RID: 2349 + // (get) Token: 0x06001B10 RID: 6928 RVA: 0x000535F5 File Offset: 0x000517F5 + public virtual IList Controls + { + get + { + if (this._controls == null) + { + this._controls = new List(); + } + return this._controls; + } + } + + // Token: 0x06001B11 RID: 6929 RVA: 0x00053610 File Offset: 0x00051810 + protected override void OnWriteBodyContents(XmlDictionaryWriter writer) + { + writer.WriteStartElement("Pull", "http://schemas.xmlsoap.org/ws/2004/09/enumeration"); + if (this._enumerationContext != null) + { + writer.WriteElementString("EnumerationContext", "http://schemas.xmlsoap.org/ws/2004/09/enumeration", this._enumerationContext); + } + if (this._timeout != null) + { + writer.WriteStartElement("MaxTime", "http://schemas.xmlsoap.org/ws/2004/09/enumeration"); + writer.WriteValue(this._timeout.Value); + writer.WriteEndElement(); + } + if (this._maxElements != null) + { + writer.WriteStartElement("MaxElements", "http://schemas.xmlsoap.org/ws/2004/09/enumeration"); + writer.WriteValue((long)((ulong)this._maxElements.Value)); + writer.WriteEndElement(); + } + if (this._controls != null) + { + DirectoryControlSerializer.Serialize(writer, this._controls); + } + writer.WriteEndElement(); + } + + // Token: 0x06001B12 RID: 6930 RVA: 0x000536CE File Offset: 0x000518CE + protected override void OnWriteStartBody(XmlDictionaryWriter writer) + { + base.OnWriteStartBody(writer); + writer.WriteXmlnsAttribute("wsen", "http://schemas.xmlsoap.org/ws/2004/09/enumeration"); + } + + // Token: 0x06001B13 RID: 6931 RVA: 0x000536E7 File Offset: 0x000518E7 + public virtual void SetTimeout(TimeSpan timeout) + { + this._timeout = new TimeSpan?(timeout); + } + + // Token: 0x04000C91 RID: 3217 + private TimeSpan? _timeout; + + // Token: 0x04000C92 RID: 3218 + private uint? _maxElements; + + // Token: 0x04000C93 RID: 3219 + private string _enumerationContext; + + // Token: 0x04000C94 RID: 3220 + private IList _controls; + } +} diff --git a/SnaffCore/ActiveDirectory/Management/WSE/ADReleaseRequest.cs b/SnaffCore/ActiveDirectory/Management/WSE/ADReleaseRequest.cs new file mode 100644 index 00000000..d161aefb --- /dev/null +++ b/SnaffCore/ActiveDirectory/Management/WSE/ADReleaseRequest.cs @@ -0,0 +1,44 @@ +using System; +using System.Xml; + +namespace Microsoft.ActiveDirectory.Management.WSE +{ + // Token: 0x02000314 RID: 788 + internal class ADReleaseRequest : AdwsRequestMsg + { + // Token: 0x06001B1C RID: 6940 RVA: 0x0005380B File Offset: 0x00051A0B + public ADReleaseRequest(string instance, string enumerationContext) + : base(instance) + { + this._enumerationContext = enumerationContext; + } + + // Token: 0x17000932 RID: 2354 + // (get) Token: 0x06001B1D RID: 6941 RVA: 0x0005381B File Offset: 0x00051A1B + public override string Action + { + get + { + return "http://schemas.xmlsoap.org/ws/2004/09/enumeration/Release"; + } + } + + // Token: 0x06001B1E RID: 6942 RVA: 0x00053822 File Offset: 0x00051A22 + protected override void OnWriteStartBody(XmlDictionaryWriter writer) + { + base.OnWriteStartBody(writer); + writer.WriteXmlnsAttribute("wsen", "http://schemas.xmlsoap.org/ws/2004/09/enumeration"); + } + + // Token: 0x06001B1F RID: 6943 RVA: 0x0005383B File Offset: 0x00051A3B + protected override void OnWriteBodyContents(XmlDictionaryWriter writer) + { + writer.WriteStartElement("Release", "http://schemas.xmlsoap.org/ws/2004/09/enumeration"); + XmlUtility.SerializeEnumerationContext(writer, this._enumerationContext); + writer.WriteEndElement(); + } + + // Token: 0x04000C98 RID: 3224 + private string _enumerationContext; + } +} diff --git a/SnaffCore/ActiveDirectory/Management/WSE/ADRenewRequest.cs b/SnaffCore/ActiveDirectory/Management/WSE/ADRenewRequest.cs new file mode 100644 index 00000000..00ec21a9 --- /dev/null +++ b/SnaffCore/ActiveDirectory/Management/WSE/ADRenewRequest.cs @@ -0,0 +1,65 @@ +using System; +using System.Xml; + +namespace Microsoft.ActiveDirectory.Management.WSE +{ + // Token: 0x02000316 RID: 790 + internal class ADRenewRequest : AdwsRequestMsg + { + // Token: 0x06001B25 RID: 6949 RVA: 0x00053882 File Offset: 0x00051A82 + public ADRenewRequest(string instance, string enumerationContext) + : base(instance) + { + this._enumerationContext = enumerationContext; + } + + // Token: 0x17000935 RID: 2357 + // (get) Token: 0x06001B26 RID: 6950 RVA: 0x00053892 File Offset: 0x00051A92 + public override string Action + { + get + { + return "http://schemas.xmlsoap.org/ws/2004/09/enumeration/Renew"; + } + } + + // Token: 0x06001B27 RID: 6951 RVA: 0x00053899 File Offset: 0x00051A99 + protected override void OnWriteStartBody(XmlDictionaryWriter writer) + { + base.OnWriteStartBody(writer); + writer.WriteXmlnsAttribute("wsen", "http://schemas.xmlsoap.org/ws/2004/09/enumeration"); + } + + // Token: 0x06001B28 RID: 6952 RVA: 0x000538B2 File Offset: 0x00051AB2 + protected override void OnWriteBodyContents(XmlDictionaryWriter writer) + { + writer.WriteStartElement("Renew", "http://schemas.xmlsoap.org/ws/2004/09/enumeration"); + XmlUtility.SerializeEnumerationContext(writer, this._enumerationContext); + XmlUtility.SerializeExpires(writer, this._expirationDateTime, this._expirationTimeSpan); + writer.WriteEndElement(); + } + + // Token: 0x06001B29 RID: 6953 RVA: 0x000538E8 File Offset: 0x00051AE8 + public virtual void SetContextExpiration(DateTime expiration) + { + this._expirationDateTime = new DateTime?(expiration); + this._expirationTimeSpan = null; + } + + // Token: 0x06001B2A RID: 6954 RVA: 0x00053902 File Offset: 0x00051B02 + public virtual void SetContextExpiration(TimeSpan expiration) + { + this._expirationTimeSpan = new TimeSpan?(expiration); + this._expirationDateTime = null; + } + + // Token: 0x04000C99 RID: 3225 + private string _enumerationContext; + + // Token: 0x04000C9A RID: 3226 + private DateTime? _expirationDateTime; + + // Token: 0x04000C9B RID: 3227 + private TimeSpan? _expirationTimeSpan; + } +} diff --git a/SnaffCore/ActiveDirectory/Management/XmlUtility.cs b/SnaffCore/ActiveDirectory/Management/XmlUtility.cs new file mode 100644 index 00000000..a4655372 --- /dev/null +++ b/SnaffCore/ActiveDirectory/Management/XmlUtility.cs @@ -0,0 +1,238 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.ServiceModel.Channels; +using System.Text.RegularExpressions; +using System.Xml; + +namespace Microsoft.ActiveDirectory.Management +{ + // Token: 0x020000B4 RID: 180 + internal class XmlUtility + { + // Token: 0x060004CA RID: 1226 RVA: 0x00011A78 File Offset: 0x0000FC78 + private XmlUtility() + { + } + + // Token: 0x060004CB RID: 1227 RVA: 0x00011A80 File Offset: 0x0000FC80 + public static bool SplitLdapAttributeOnOption(string ldapAttribute, ref string splitAttribute, ref string splitOption) + { + int num = ldapAttribute.IndexOf(LdapOptionConstants.LdapOptionSeperator, StringComparison.Ordinal); + if (-1 == num) + { + return false; + } + splitAttribute = ldapAttribute.Substring(0, num); + splitOption = ldapAttribute.Substring(num + 1); + if (string.IsNullOrEmpty(splitOption)) + { + throw new ArgumentException("Invalid Format"); + } + return true; + } + + // Token: 0x060004CC RID: 1228 RVA: 0x00011ACC File Offset: 0x0000FCCC + public static void SerializeLdapAttributeOption(XmlDictionaryWriter writer, string ldapOptions) + { + Match match = LdapOptionConstants.RangeOptionRegex.Match(ldapOptions); + if (!match.Success || !match.Groups[LdapOptionConstants.HighRangeIndex].Success || !match.Groups[LdapOptionConstants.LowRangeIndex].Success) + { + throw new ArgumentException("Invalid Format"); + } + writer.WriteAttributeString("RangeLow", string.Empty, match.Groups[LdapOptionConstants.LowRangeIndex].Value); + writer.WriteAttributeString("RangeHigh", string.Empty, match.Groups[LdapOptionConstants.HighRangeIndex].Value); + } + + // Token: 0x060004CD RID: 1229 RVA: 0x00011B70 File Offset: 0x0000FD70 + public static bool DeserializeLdapAttributeOption(XmlReader reader, ref string ldapAttribute) + { + if (reader.AttributeCount > 1) + { + string attribute = reader.GetAttribute("RangeLow", string.Empty); + if (!string.IsNullOrEmpty(attribute)) + { + string attribute2 = reader.GetAttribute("RangeHigh", string.Empty); + if (!string.IsNullOrEmpty(attribute2)) + { + ldapAttribute = string.Format(LdapOptionConstants.RangeOptionFormatString, ldapAttribute, attribute, attribute2); + return true; + } + throw new ADException(); + } + } + return false; + } + + // Token: 0x060004CE RID: 1230 RVA: 0x00011BD4 File Offset: 0x0000FDD4 + public static void SerializeAttributeList(XmlDictionaryWriter writer, string xmlAttribute, string ns, string syntheticPrefix, string attrPrefix, IList attributes) + { + bool flag = false; + foreach (string text in attributes) + { + if (AttributeNs.IsSynthetic(text, SyntheticAttributeOperation.Read, ref flag)) + { + writer.WriteElementString(xmlAttribute, ns, flag ? text : XmlUtility.AddPrefix(syntheticPrefix, text)); + } + else + { + string text2 = null; + string text3 = null; + if (XmlUtility.SplitLdapAttributeOnOption(text, ref text2, ref text3)) + { + writer.WriteStartElement(xmlAttribute, ns); + XmlUtility.SerializeLdapAttributeOption(writer, text3); + writer.WriteValue(XmlUtility.AddPrefix(attrPrefix, text2)); + writer.WriteEndElement(); + } + else + { + writer.WriteElementString(xmlAttribute, ns, XmlUtility.AddPrefix(attrPrefix, text)); + } + } + } + } + + // Token: 0x060004CF RID: 1231 RVA: 0x00011C84 File Offset: 0x0000FE84 + public static void SerializeExpires(XmlDictionaryWriter writer, DateTime? dateTimeFormat, TimeSpan? timeSpanFormat) + { + if (dateTimeFormat != null || timeSpanFormat != null) + { + writer.WriteStartElement("Expires", "http://schemas.xmlsoap.org/ws/2004/09/enumeration"); + if (dateTimeFormat != null) + { + writer.WriteValue(XmlConvert.ToString(dateTimeFormat.Value, XmlDateTimeSerializationMode.Utc)); + } + else + { + writer.WriteValue(XmlConvert.ToString(timeSpanFormat.Value)); + } + writer.WriteEndElement(); + } + } + + // Token: 0x060004D0 RID: 1232 RVA: 0x00011CEC File Offset: 0x0000FEEC + public static void DeserializeExpiresIfNeeded(XmlDictionaryReader reader, ref DateTime? dateTimeFormat, ref TimeSpan? timeSpanFormat) + { + if (reader.IsStartElement("Expires", "http://schemas.xmlsoap.org/ws/2004/09/enumeration")) + { + string text = reader.ReadElementString(); + if (text.StartsWith("P", StringComparison.OrdinalIgnoreCase)) + { + timeSpanFormat = new TimeSpan?(XmlConvert.ToTimeSpan(text)); + return; + } + dateTimeFormat = new DateTime?(XmlConvert.ToDateTime(text, XmlDateTimeSerializationMode.Utc)); + } + } + + // Token: 0x060004D1 RID: 1233 RVA: 0x00011D44 File Offset: 0x0000FF44 + public static string ConvertADAttributeValToXml(object value) + { + if (value is byte[]) + { + return Convert.ToBase64String((byte[])value); + } + return (string)value; + } + + // Token: 0x060004D2 RID: 1234 RVA: 0x00011D60 File Offset: 0x0000FF60 + public static void SerializeEnumerationContext(XmlDictionaryWriter writer, string context) + { + writer.WriteElementString("EnumerationContext", "http://schemas.xmlsoap.org/ws/2004/09/enumeration", context); + } + + // Token: 0x060004D3 RID: 1235 RVA: 0x00011D73 File Offset: 0x0000FF73 + public static string DeserializeEunmerationContext(XmlDictionaryReader reader) + { + if (reader.IsStartElement("EnumerationContext", "http://schemas.xmlsoap.org/ws/2004/09/enumeration")) + { + return reader.ReadElementString("EnumerationContext", "http://schemas.xmlsoap.org/ws/2004/09/enumeration"); + } + return null; + } + + // Token: 0x060004D4 RID: 1236 RVA: 0x00011D9C File Offset: 0x0000FF9C + public static void WriteXsiTypeAttribute(XmlDictionaryWriter writer, string xsdType) + { + string text = writer.LookupPrefix("http://www.w3.org/2001/XMLSchema"); + writer.WriteAttributeString("type", "http://www.w3.org/2001/XMLSchema-instance", string.Format(CultureInfo.CurrentCulture, "{0}:{1}", text, xsdType)); + } + + // Token: 0x060004D5 RID: 1237 RVA: 0x00011DD8 File Offset: 0x0000FFD8 + public static void MarkHeaderAsUnderstood(MessageHeaders headers, string localName, string ns) + { + int num = headers.FindHeader(localName, ns); + if (-1 == num) + { + return; + } + if (!headers.UnderstoodHeaders.Contains(headers[num])) + { + headers.UnderstoodHeaders.Add(headers[num]); + } + } + + // Token: 0x060004D6 RID: 1238 RVA: 0x00011E19 File Offset: 0x00010019 + public static string AddPrefix(string prefix, string element) + { + return string.Format(CultureInfo.InvariantCulture, "{0}:{1}", prefix, element); + } + + // Token: 0x060004D7 RID: 1239 RVA: 0x00011E2C File Offset: 0x0001002C + public static string RemovePrefix(string prefix, string element) + { + if (!string.IsNullOrEmpty(element)) + { + string text = prefix + ":"; + if (element.StartsWith(text, StringComparison.Ordinal)) + { + return element.Substring(text.Length); + } + } + return element; + } + + // Token: 0x060004D8 RID: 1240 RVA: 0x00011E68 File Offset: 0x00010068 + public static void SplitPrefix(string name, out string prefix, out string localName) + { + string[] array = name.Split(new char[] { ':' }); + if (array.Length == 1) + { + localName = array[0]; + prefix = null; + return; + } + prefix = array[0]; + localName = array[1]; + } + + // Token: 0x060004D9 RID: 1241 RVA: 0x00011EA0 File Offset: 0x000100A0 + public static bool ValidateNamespace(XmlReader reader, string value, string ns) + { + string[] array = value.Split(new char[] { ':' }); + if (array.Length == 1) + { + return string.Compare(reader.NamespaceURI, ns, StringComparison.OrdinalIgnoreCase) == 0; + } + string text = array[0]; + return string.Equals(reader.LookupNamespace(text), ns, StringComparison.Ordinal); + } + + // Token: 0x060004DA RID: 1242 RVA: 0x00011EE8 File Offset: 0x000100E8 + public static void DeserializeObjectReference(XmlReader reader, out string objectReference) + { + if (!reader.IsStartElement("objectReferenceProperty", "http://schemas.microsoft.com/2008/1/ActiveDirectory")) + { + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.ADWSXmlParserInvalidelement, "ad", "objectReferenceProperty")); + } + string text; + objectReference = (text = reader.ReadString()); + if (text == null) + { + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.ADWSXmlParserInvalidelement, "ad", "objectReferenceProperty")); + } + reader.Read(); + } + } +} diff --git a/SnaffCore/ActiveDirectory/WebServices/Proxy/ArgumentErrorDetail.cs b/SnaffCore/ActiveDirectory/WebServices/Proxy/ArgumentErrorDetail.cs new file mode 100644 index 00000000..50a87389 --- /dev/null +++ b/SnaffCore/ActiveDirectory/WebServices/Proxy/ArgumentErrorDetail.cs @@ -0,0 +1,74 @@ +using System; +using System.CodeDom.Compiler; +using System.ComponentModel; +using System.Diagnostics; +using System.Xml.Serialization; + +namespace Microsoft.ActiveDirectory.WebServices.Proxy +{ + // Token: 0x0200003E RID: 62 + [GeneratedCode("svcutil", "3.0.4506.2123")] + [DebuggerStepThrough] + [DesignerCategory("code")] + [XmlType(Namespace = "http://schemas.microsoft.com/2008/1/ActiveDirectory")] + [Serializable] + public class ArgumentErrorDetail + { + // Token: 0x17000066 RID: 102 + // (get) Token: 0x06000140 RID: 320 RVA: 0x00002E96 File Offset: 0x00001096 + // (set) Token: 0x06000141 RID: 321 RVA: 0x00002E9E File Offset: 0x0000109E + [XmlElement(Order = 0)] + public string Message + { + get + { + return this.messageField; + } + set + { + this.messageField = value; + } + } + + // Token: 0x17000067 RID: 103 + // (get) Token: 0x06000142 RID: 322 RVA: 0x00002EA7 File Offset: 0x000010A7 + // (set) Token: 0x06000143 RID: 323 RVA: 0x00002EAF File Offset: 0x000010AF + [XmlElement(Order = 1)] + public string ParameterName + { + get + { + return this.parameterNameField; + } + set + { + this.parameterNameField = value; + } + } + + // Token: 0x17000068 RID: 104 + // (get) Token: 0x06000144 RID: 324 RVA: 0x00002EB8 File Offset: 0x000010B8 + // (set) Token: 0x06000145 RID: 325 RVA: 0x00002EC0 File Offset: 0x000010C0 + [XmlElement(Order = 2)] + public string ShortMessage + { + get + { + return this.shortMessageField; + } + set + { + this.shortMessageField = value; + } + } + + // Token: 0x040001E7 RID: 487 + private string messageField; + + // Token: 0x040001E8 RID: 488 + private string parameterNameField; + + // Token: 0x040001E9 RID: 489 + private string shortMessageField; + } +} diff --git a/SnaffCore/ActiveDirectory/WebServices/Proxy/AttributeTypeAndValue.cs b/SnaffCore/ActiveDirectory/WebServices/Proxy/AttributeTypeAndValue.cs new file mode 100644 index 00000000..d7af067d --- /dev/null +++ b/SnaffCore/ActiveDirectory/WebServices/Proxy/AttributeTypeAndValue.cs @@ -0,0 +1,57 @@ +using System; +using System.CodeDom.Compiler; +using System.ComponentModel; +using System.Data; +using System.Diagnostics; +using System.Xml.Serialization; + +namespace Microsoft.ActiveDirectory.WebServices.Proxy +{ + // Token: 0x0200003F RID: 63 + [XmlInclude(typeof(ChangeType))] + [GeneratedCode("svcutil", "3.0.4506.2123")] + [DebuggerStepThrough] + [DesignerCategory("code")] + [XmlType(Namespace = "http://schemas.microsoft.com/2006/11/IdentityManagement/DirectoryAccess")] + [Serializable] + public class AttributeTypeAndValue + { + // Token: 0x17000069 RID: 105 + // (get) Token: 0x06000147 RID: 327 RVA: 0x00002ED1 File Offset: 0x000010D1 + // (set) Token: 0x06000148 RID: 328 RVA: 0x00002ED9 File Offset: 0x000010D9 + [XmlElement(Order = 0)] + public DataSet AttributeType + { + get + { + return this.attributeTypeField; + } + set + { + this.attributeTypeField = value; + } + } + + // Token: 0x1700006A RID: 106 + // (get) Token: 0x06000149 RID: 329 RVA: 0x00002EE2 File Offset: 0x000010E2 + // (set) Token: 0x0600014A RID: 330 RVA: 0x00002EEA File Offset: 0x000010EA + [XmlElement(Order = 1)] + public DataSet AttributeValue + { + get + { + return this.attributeValueField; + } + set + { + this.attributeValueField = value; + } + } + + // Token: 0x040001EA RID: 490 + private DataSet attributeTypeField; + + // Token: 0x040001EB RID: 491 + private DataSet attributeValueField; + } +} diff --git a/SnaffCore/ActiveDirectory/WebServices/Proxy/AttributeTypeNotValid.cs b/SnaffCore/ActiveDirectory/WebServices/Proxy/AttributeTypeNotValid.cs new file mode 100644 index 00000000..9c51c8c6 --- /dev/null +++ b/SnaffCore/ActiveDirectory/WebServices/Proxy/AttributeTypeNotValid.cs @@ -0,0 +1,56 @@ +using System; +using System.CodeDom.Compiler; +using System.ComponentModel; +using System.Diagnostics; +using System.Xml.Serialization; + +namespace Microsoft.ActiveDirectory.WebServices.Proxy +{ + // Token: 0x02000047 RID: 71 + [GeneratedCode("svcutil", "3.0.4506.2123")] + [DebuggerStepThrough] + [DesignerCategory("code")] + [XmlType(Namespace = "http://schemas.microsoft.com/2006/11/IdentityManagement/DirectoryAccess")] + [XmlRoot(Namespace = "http://schemas.microsoft.com/2006/11/IdentityManagement/DirectoryAccess")] + [Serializable] + public class AttributeTypeNotValid + { + // Token: 0x17000079 RID: 121 + // (get) Token: 0x0600016F RID: 367 RVA: 0x00003021 File Offset: 0x00001221 + // (set) Token: 0x06000170 RID: 368 RVA: 0x00003029 File Offset: 0x00001229 + [XmlElement(Order = 0)] + public AttributeTypeNotValidForDialect AttributeTypeNotValidForDialect + { + get + { + return this.attributeTypeNotValidForDialectField; + } + set + { + this.attributeTypeNotValidForDialectField = value; + } + } + + // Token: 0x1700007A RID: 122 + // (get) Token: 0x06000171 RID: 369 RVA: 0x00003032 File Offset: 0x00001232 + // (set) Token: 0x06000172 RID: 370 RVA: 0x0000303A File Offset: 0x0000123A + [XmlElement(Order = 1)] + public AttributeTypeNotValidForEntry AttributeTypeNotValidForEntry + { + get + { + return this.attributeTypeNotValidForEntryField; + } + set + { + this.attributeTypeNotValidForEntryField = value; + } + } + + // Token: 0x040001FA RID: 506 + private AttributeTypeNotValidForDialect attributeTypeNotValidForDialectField; + + // Token: 0x040001FB RID: 507 + private AttributeTypeNotValidForEntry attributeTypeNotValidForEntryField; + } +} diff --git a/SnaffCore/ActiveDirectory/WebServices/Proxy/AttributeTypeNotValidForDialect.cs b/SnaffCore/ActiveDirectory/WebServices/Proxy/AttributeTypeNotValidForDialect.cs new file mode 100644 index 00000000..5baad9cf --- /dev/null +++ b/SnaffCore/ActiveDirectory/WebServices/Proxy/AttributeTypeNotValidForDialect.cs @@ -0,0 +1,36 @@ +using System; +using System.CodeDom.Compiler; +using System.ComponentModel; +using System.Diagnostics; +using System.Xml.Serialization; + +namespace Microsoft.ActiveDirectory.WebServices.Proxy +{ + // Token: 0x02000048 RID: 72 + [GeneratedCode("svcutil", "3.0.4506.2123")] + [DebuggerStepThrough] + [DesignerCategory("code")] + [XmlType(Namespace = "http://schemas.microsoft.com/2006/11/IdentityManagement/DirectoryAccess")] + [Serializable] + public class AttributeTypeNotValidForDialect + { + // Token: 0x1700007B RID: 123 + // (get) Token: 0x06000174 RID: 372 RVA: 0x0000304B File Offset: 0x0000124B + // (set) Token: 0x06000175 RID: 373 RVA: 0x00003053 File Offset: 0x00001253 + [XmlElement(Order = 0)] + public string AttributeType + { + get + { + return this.attributeTypeField; + } + set + { + this.attributeTypeField = value; + } + } + + // Token: 0x040001FC RID: 508 + private string attributeTypeField; + } +} diff --git a/SnaffCore/ActiveDirectory/WebServices/Proxy/AttributeTypeNotValidForEntry.cs b/SnaffCore/ActiveDirectory/WebServices/Proxy/AttributeTypeNotValidForEntry.cs new file mode 100644 index 00000000..5a69a10c --- /dev/null +++ b/SnaffCore/ActiveDirectory/WebServices/Proxy/AttributeTypeNotValidForEntry.cs @@ -0,0 +1,36 @@ +using System; +using System.CodeDom.Compiler; +using System.ComponentModel; +using System.Diagnostics; +using System.Xml.Serialization; + +namespace Microsoft.ActiveDirectory.WebServices.Proxy +{ + // Token: 0x02000049 RID: 73 + [GeneratedCode("svcutil", "3.0.4506.2123")] + [DebuggerStepThrough] + [DesignerCategory("code")] + [XmlType(Namespace = "http://schemas.microsoft.com/2006/11/IdentityManagement/DirectoryAccess")] + [Serializable] + public class AttributeTypeNotValidForEntry + { + // Token: 0x1700007C RID: 124 + // (get) Token: 0x06000177 RID: 375 RVA: 0x00003064 File Offset: 0x00001264 + // (set) Token: 0x06000178 RID: 376 RVA: 0x0000306C File Offset: 0x0000126C + [XmlElement(Order = 0)] + public string AttributeType + { + get + { + return this.attributeTypeField; + } + set + { + this.attributeTypeField = value; + } + } + + // Token: 0x040001FD RID: 509 + private string attributeTypeField; + } +} diff --git a/SnaffCore/ActiveDirectory/WebServices/Proxy/ChangeType.cs b/SnaffCore/ActiveDirectory/WebServices/Proxy/ChangeType.cs new file mode 100644 index 00000000..da0bd7f6 --- /dev/null +++ b/SnaffCore/ActiveDirectory/WebServices/Proxy/ChangeType.cs @@ -0,0 +1,36 @@ +using System; +using System.CodeDom.Compiler; +using System.ComponentModel; +using System.Diagnostics; +using System.Xml.Serialization; + +namespace Microsoft.ActiveDirectory.WebServices.Proxy +{ + // Token: 0x02000040 RID: 64 + [GeneratedCode("svcutil", "3.0.4506.2123")] + [DebuggerStepThrough] + [DesignerCategory("code")] + [XmlType(Namespace = "http://schemas.microsoft.com/2006/11/IdentityManagement/DirectoryAccess")] + [Serializable] + public class ChangeType : AttributeTypeAndValue + { + // Token: 0x1700006B RID: 107 + // (get) Token: 0x0600014C RID: 332 RVA: 0x00002EFB File Offset: 0x000010FB + // (set) Token: 0x0600014D RID: 333 RVA: 0x00002F03 File Offset: 0x00001103 + [XmlAttribute] + public string Operation + { + get + { + return this.operationField; + } + set + { + this.operationField = value; + } + } + + // Token: 0x040001EC RID: 492 + private string operationField; + } +} diff --git a/SnaffCore/ActiveDirectory/WebServices/Proxy/DirectoryErrorDetail.cs b/SnaffCore/ActiveDirectory/WebServices/Proxy/DirectoryErrorDetail.cs new file mode 100644 index 00000000..137b967d --- /dev/null +++ b/SnaffCore/ActiveDirectory/WebServices/Proxy/DirectoryErrorDetail.cs @@ -0,0 +1,150 @@ +using System; +using System.CodeDom.Compiler; +using System.ComponentModel; +using System.Diagnostics; +using System.Xml.Serialization; + +namespace Microsoft.ActiveDirectory.WebServices.Proxy +{ + // Token: 0x02000041 RID: 65 + [GeneratedCode("svcutil", "3.0.4506.2123")] + [DebuggerStepThrough] + [DesignerCategory("code")] + [XmlType(Namespace = "http://schemas.microsoft.com/2008/1/ActiveDirectory")] + [Serializable] + public class DirectoryErrorDetail + { + // Token: 0x1700006C RID: 108 + // (get) Token: 0x0600014F RID: 335 RVA: 0x00002F14 File Offset: 0x00001114 + // (set) Token: 0x06000150 RID: 336 RVA: 0x00002F1C File Offset: 0x0000111C + [XmlElement(Order = 0)] + public string Message + { + get + { + return this.messageField; + } + set + { + this.messageField = value; + } + } + + // Token: 0x1700006D RID: 109 + // (get) Token: 0x06000151 RID: 337 RVA: 0x00002F25 File Offset: 0x00001125 + // (set) Token: 0x06000152 RID: 338 RVA: 0x00002F2D File Offset: 0x0000112D + [XmlElement(Order = 1)] + public string ErrorCode + { + get + { + return this.errorCodeField; + } + set + { + this.errorCodeField = value; + } + } + + // Token: 0x1700006E RID: 110 + // (get) Token: 0x06000153 RID: 339 RVA: 0x00002F36 File Offset: 0x00001136 + // (set) Token: 0x06000154 RID: 340 RVA: 0x00002F3E File Offset: 0x0000113E + [XmlElement(Order = 2)] + public string ExtendedErrorMessage + { + get + { + return this.extendedErrorMessageField; + } + set + { + this.extendedErrorMessageField = value; + } + } + + // Token: 0x1700006F RID: 111 + // (get) Token: 0x06000155 RID: 341 RVA: 0x00002F47 File Offset: 0x00001147 + // (set) Token: 0x06000156 RID: 342 RVA: 0x00002F4F File Offset: 0x0000114F + [XmlElement(Order = 3)] + public string MatchedDN + { + get + { + return this.matchedDNField; + } + set + { + this.matchedDNField = value; + } + } + + // Token: 0x17000070 RID: 112 + // (get) Token: 0x06000157 RID: 343 RVA: 0x00002F58 File Offset: 0x00001158 + // (set) Token: 0x06000158 RID: 344 RVA: 0x00002F60 File Offset: 0x00001160 + [XmlElement("Referral", Order = 4)] + public string[] Referral + { + get + { + return this.referralField; + } + set + { + this.referralField = value; + } + } + + // Token: 0x17000071 RID: 113 + // (get) Token: 0x06000159 RID: 345 RVA: 0x00002F69 File Offset: 0x00001169 + // (set) Token: 0x0600015A RID: 346 RVA: 0x00002F71 File Offset: 0x00001171 + [XmlElement(Order = 5)] + public string Win32ErrorCode + { + get + { + return this.win32ErrorCodeField; + } + set + { + this.win32ErrorCodeField = value; + } + } + + // Token: 0x17000072 RID: 114 + // (get) Token: 0x0600015B RID: 347 RVA: 0x00002F7A File Offset: 0x0000117A + // (set) Token: 0x0600015C RID: 348 RVA: 0x00002F82 File Offset: 0x00001182 + [XmlElement(Order = 6)] + public string ShortMessage + { + get + { + return this.shortMessageField; + } + set + { + this.shortMessageField = value; + } + } + + // Token: 0x040001ED RID: 493 + private string messageField; + + // Token: 0x040001EE RID: 494 + private string errorCodeField; + + // Token: 0x040001EF RID: 495 + private string extendedErrorMessageField; + + // Token: 0x040001F0 RID: 496 + private string matchedDNField; + + // Token: 0x040001F1 RID: 497 + private string[] referralField; + + // Token: 0x040001F2 RID: 498 + private string win32ErrorCodeField; + + // Token: 0x040001F3 RID: 499 + private string shortMessageField; + } +} diff --git a/SnaffCore/ActiveDirectory/WebServices/Proxy/EnumerateFault.cs b/SnaffCore/ActiveDirectory/WebServices/Proxy/EnumerateFault.cs new file mode 100644 index 00000000..3c14e5ee --- /dev/null +++ b/SnaffCore/ActiveDirectory/WebServices/Proxy/EnumerateFault.cs @@ -0,0 +1,37 @@ +using System; +using System.CodeDom.Compiler; +using System.ComponentModel; +using System.Diagnostics; +using System.Xml.Serialization; + +namespace Microsoft.ActiveDirectory.WebServices.Proxy +{ + // Token: 0x02000044 RID: 68 + [GeneratedCode("svcutil", "3.0.4506.2123")] + [DebuggerStepThrough] + [DesignerCategory("code")] + [XmlType(Namespace = "http://schemas.microsoft.com/2008/1/ActiveDirectory")] + [XmlRoot(Namespace = "http://schemas.microsoft.com/2008/1/ActiveDirectory")] + [Serializable] + public class EnumerateFault : FaultDetail + { + // Token: 0x17000073 RID: 115 + // (get) Token: 0x06000160 RID: 352 RVA: 0x00002FA3 File Offset: 0x000011A3 + // (set) Token: 0x06000161 RID: 353 RVA: 0x00002FAB File Offset: 0x000011AB + [XmlElement(Order = 0)] + public string InvalidProperty + { + get + { + return this.invalidPropertyField; + } + set + { + this.invalidPropertyField = value; + } + } + + // Token: 0x040001F4 RID: 500 + private string invalidPropertyField; + } +} diff --git a/SnaffCore/ActiveDirectory/WebServices/Proxy/FaultDetail.cs b/SnaffCore/ActiveDirectory/WebServices/Proxy/FaultDetail.cs new file mode 100644 index 00000000..ce822752 --- /dev/null +++ b/SnaffCore/ActiveDirectory/WebServices/Proxy/FaultDetail.cs @@ -0,0 +1,192 @@ +using System; +using System.CodeDom.Compiler; +using System.ComponentModel; +using System.Diagnostics; +using System.Xml.Serialization; + +namespace Microsoft.ActiveDirectory.WebServices.Proxy +{ + // Token: 0x0200003D RID: 61 + [XmlInclude(typeof(RenewFault))] + [XmlInclude(typeof(PullFault))] + [XmlInclude(typeof(EnumerateFault))] + [GeneratedCode("svcutil", "3.0.4506.2123")] + [DebuggerStepThrough] + [DesignerCategory("code")] + [XmlType(Namespace = "http://schemas.microsoft.com/2008/1/ActiveDirectory")] + [XmlRoot(Namespace = "http://schemas.microsoft.com/2008/1/ActiveDirectory")] + [Serializable] + public class FaultDetail + { + // Token: 0x1700005D RID: 93 + // (get) Token: 0x0600012D RID: 301 RVA: 0x00002DF5 File Offset: 0x00000FF5 + // (set) Token: 0x0600012E RID: 302 RVA: 0x00002DFD File Offset: 0x00000FFD + [XmlElement(Order = 0)] + public ArgumentErrorDetail ArgumentError + { + get + { + return this.argumentErrorField; + } + set + { + this.argumentErrorField = value; + } + } + + // Token: 0x1700005E RID: 94 + // (get) Token: 0x0600012F RID: 303 RVA: 0x00002E06 File Offset: 0x00001006 + // (set) Token: 0x06000130 RID: 304 RVA: 0x00002E0E File Offset: 0x0000100E + [XmlElement(Order = 1)] + public string Error + { + get + { + return this.errorField; + } + set + { + this.errorField = value; + } + } + + // Token: 0x1700005F RID: 95 + // (get) Token: 0x06000131 RID: 305 RVA: 0x00002E17 File Offset: 0x00001017 + // (set) Token: 0x06000132 RID: 306 RVA: 0x00002E1F File Offset: 0x0000101F + [XmlElement(Order = 2)] + public DirectoryErrorDetail DirectoryError + { + get + { + return this.directoryErrorField; + } + set + { + this.directoryErrorField = value; + } + } + + // Token: 0x17000060 RID: 96 + // (get) Token: 0x06000133 RID: 307 RVA: 0x00002E28 File Offset: 0x00001028 + // (set) Token: 0x06000134 RID: 308 RVA: 0x00002E30 File Offset: 0x00001030 + [XmlElement(Order = 3)] + public string InvalidAttributeType + { + get + { + return this.invalidAttributeTypeField; + } + set + { + this.invalidAttributeTypeField = value; + } + } + + // Token: 0x17000061 RID: 97 + // (get) Token: 0x06000135 RID: 309 RVA: 0x00002E39 File Offset: 0x00001039 + // (set) Token: 0x06000136 RID: 310 RVA: 0x00002E41 File Offset: 0x00001041 + [XmlElement(Order = 4)] + public string InvalidOperation + { + get + { + return this.invalidOperationField; + } + set + { + this.invalidOperationField = value; + } + } + + // Token: 0x17000062 RID: 98 + // (get) Token: 0x06000137 RID: 311 RVA: 0x00002E4A File Offset: 0x0000104A + // (set) Token: 0x06000138 RID: 312 RVA: 0x00002E52 File Offset: 0x00001052 + [XmlElement(Order = 5)] + public ChangeType InvalidChange + { + get + { + return this.invalidChangeField; + } + set + { + this.invalidChangeField = value; + } + } + + // Token: 0x17000063 RID: 99 + // (get) Token: 0x06000139 RID: 313 RVA: 0x00002E5B File Offset: 0x0000105B + // (set) Token: 0x0600013A RID: 314 RVA: 0x00002E63 File Offset: 0x00001063 + [XmlElement(Order = 6)] + public AttributeTypeAndValue InvalidAttributeTypeOrValue + { + get + { + return this.invalidAttributeTypeOrValueField; + } + set + { + this.invalidAttributeTypeOrValueField = value; + } + } + + // Token: 0x17000064 RID: 100 + // (get) Token: 0x0600013B RID: 315 RVA: 0x00002E6C File Offset: 0x0000106C + // (set) Token: 0x0600013C RID: 316 RVA: 0x00002E74 File Offset: 0x00001074 + [XmlElement(Order = 7)] + public string ShortError + { + get + { + return this.shortErrorField; + } + set + { + this.shortErrorField = value; + } + } + + // Token: 0x17000065 RID: 101 + // (get) Token: 0x0600013D RID: 317 RVA: 0x00002E7D File Offset: 0x0000107D + // (set) Token: 0x0600013E RID: 318 RVA: 0x00002E85 File Offset: 0x00001085 + [XmlElement(Order = 8)] + public string UnknownAttribute + { + get + { + return this.unknownAttributeField; + } + set + { + this.unknownAttributeField = value; + } + } + + // Token: 0x040001DE RID: 478 + private ArgumentErrorDetail argumentErrorField; + + // Token: 0x040001DF RID: 479 + private string errorField; + + // Token: 0x040001E0 RID: 480 + private DirectoryErrorDetail directoryErrorField; + + // Token: 0x040001E1 RID: 481 + private string invalidAttributeTypeField; + + // Token: 0x040001E2 RID: 482 + private string invalidOperationField; + + // Token: 0x040001E3 RID: 483 + private ChangeType invalidChangeField; + + // Token: 0x040001E4 RID: 484 + private AttributeTypeAndValue invalidAttributeTypeOrValueField; + + // Token: 0x040001E5 RID: 485 + private string shortErrorField; + + // Token: 0x040001E6 RID: 486 + private string unknownAttributeField; + } +} diff --git a/SnaffCore/ActiveDirectory/WebServices/Proxy/FaultDetail1.cs b/SnaffCore/ActiveDirectory/WebServices/Proxy/FaultDetail1.cs new file mode 100644 index 00000000..7cc1022c --- /dev/null +++ b/SnaffCore/ActiveDirectory/WebServices/Proxy/FaultDetail1.cs @@ -0,0 +1,95 @@ +using System; +using System.CodeDom.Compiler; +using System.ComponentModel; +using System.Diagnostics; +using System.Xml.Schema; +using System.Xml.Serialization; + +namespace Microsoft.ActiveDirectory.WebServices.Proxy +{ + // Token: 0x02000045 RID: 69 + [GeneratedCode("svcutil", "3.0.4506.2123")] + [DebuggerStepThrough] + [DesignerCategory("code")] + [XmlType(TypeName = "FaultDetail", Namespace = "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd")] + [XmlRoot(Namespace = "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd")] + [Serializable] + public class FaultDetail1 + { + // Token: 0x17000074 RID: 116 + // (get) Token: 0x06000163 RID: 355 RVA: 0x00002FBC File Offset: 0x000011BC + // (set) Token: 0x06000164 RID: 356 RVA: 0x00002FC4 File Offset: 0x000011C4 + [XmlAttribute(Form = XmlSchemaForm.Qualified, Namespace = "http://schemas.microsoft.com/2006/11/IdentityManagement/DirectoryAccess")] + public int SizeLimit + { + get + { + return this.sizeLimitField; + } + set + { + this.sizeLimitField = value; + } + } + + // Token: 0x17000075 RID: 117 + // (get) Token: 0x06000165 RID: 357 RVA: 0x00002FCD File Offset: 0x000011CD + // (set) Token: 0x06000166 RID: 358 RVA: 0x00002FD5 File Offset: 0x000011D5 + [XmlIgnore] + public bool SizeLimitSpecified + { + get + { + return this.sizeLimitFieldSpecified; + } + set + { + this.sizeLimitFieldSpecified = value; + } + } + + // Token: 0x17000076 RID: 118 + // (get) Token: 0x06000167 RID: 359 RVA: 0x00002FDE File Offset: 0x000011DE + // (set) Token: 0x06000168 RID: 360 RVA: 0x00002FE6 File Offset: 0x000011E6 + [XmlText] + public string Value + { + get + { + return this.valueField; + } + set + { + this.valueField = value; + } + } + + // Token: 0x17000077 RID: 119 + // (get) Token: 0x06000169 RID: 361 RVA: 0x00002FEF File Offset: 0x000011EF + // (set) Token: 0x0600016A RID: 362 RVA: 0x00002FF7 File Offset: 0x000011F7 + [XmlNamespaceDeclarations] + public XmlSerializerNamespaces xmlns + { + get + { + return this.xmlnsField; + } + set + { + this.xmlnsField = value; + } + } + + // Token: 0x040001F5 RID: 501 + private int sizeLimitField; + + // Token: 0x040001F6 RID: 502 + private bool sizeLimitFieldSpecified; + + // Token: 0x040001F7 RID: 503 + private string valueField; + + // Token: 0x040001F8 RID: 504 + private XmlSerializerNamespaces xmlnsField; + } +} diff --git a/SnaffCore/ActiveDirectory/WebServices/Proxy/FragmentDialect.cs b/SnaffCore/ActiveDirectory/WebServices/Proxy/FragmentDialect.cs new file mode 100644 index 00000000..d72f9d7c --- /dev/null +++ b/SnaffCore/ActiveDirectory/WebServices/Proxy/FragmentDialect.cs @@ -0,0 +1,37 @@ +using System; +using System.CodeDom.Compiler; +using System.ComponentModel; +using System.Diagnostics; +using System.Xml.Serialization; + +namespace Microsoft.ActiveDirectory.WebServices.Proxy +{ + // Token: 0x02000046 RID: 70 + [GeneratedCode("svcutil", "3.0.4506.2123")] + [DebuggerStepThrough] + [DesignerCategory("code")] + [XmlType(Namespace = "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd")] + [XmlRoot(Namespace = "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd")] + [Serializable] + public class FragmentDialect + { + // Token: 0x17000078 RID: 120 + // (get) Token: 0x0600016C RID: 364 RVA: 0x00003008 File Offset: 0x00001208 + // (set) Token: 0x0600016D RID: 365 RVA: 0x00003010 File Offset: 0x00001210 + [XmlText(DataType = "anyURI")] + public string Value + { + get + { + return this.valueField; + } + set + { + this.valueField = value; + } + } + + // Token: 0x040001F9 RID: 505 + private string valueField; + } +} diff --git a/SnaffCore/ActiveDirectory/WebServices/Proxy/PullFault.cs b/SnaffCore/ActiveDirectory/WebServices/Proxy/PullFault.cs new file mode 100644 index 00000000..96dcec02 --- /dev/null +++ b/SnaffCore/ActiveDirectory/WebServices/Proxy/PullFault.cs @@ -0,0 +1,19 @@ +using System; +using System.CodeDom.Compiler; +using System.ComponentModel; +using System.Diagnostics; +using System.Xml.Serialization; + +namespace Microsoft.ActiveDirectory.WebServices.Proxy +{ + // Token: 0x02000043 RID: 67 + [GeneratedCode("svcutil", "3.0.4506.2123")] + [DebuggerStepThrough] + [DesignerCategory("code")] + [XmlType(Namespace = "http://schemas.microsoft.com/2008/1/ActiveDirectory")] + [XmlRoot(Namespace = "http://schemas.microsoft.com/2008/1/ActiveDirectory")] + [Serializable] + public class PullFault : FaultDetail + { + } +} diff --git a/SnaffCore/ActiveDirectory/WebServices/Proxy/RenewFault.cs b/SnaffCore/ActiveDirectory/WebServices/Proxy/RenewFault.cs new file mode 100644 index 00000000..66d8b41d --- /dev/null +++ b/SnaffCore/ActiveDirectory/WebServices/Proxy/RenewFault.cs @@ -0,0 +1,19 @@ +using System; +using System.CodeDom.Compiler; +using System.ComponentModel; +using System.Diagnostics; +using System.Xml.Serialization; + +namespace Microsoft.ActiveDirectory.WebServices.Proxy +{ + // Token: 0x02000042 RID: 66 + [GeneratedCode("svcutil", "3.0.4506.2123")] + [DebuggerStepThrough] + [DesignerCategory("code")] + [XmlType(Namespace = "http://schemas.microsoft.com/2008/1/ActiveDirectory")] + [XmlRoot(Namespace = "http://schemas.microsoft.com/2008/1/ActiveDirectory")] + [Serializable] + public class RenewFault : FaultDetail + { + } +} diff --git a/SnaffCore/ActiveDirectory/WebServices/Proxy/Resource.cs b/SnaffCore/ActiveDirectory/WebServices/Proxy/Resource.cs new file mode 100644 index 00000000..5204f0f8 --- /dev/null +++ b/SnaffCore/ActiveDirectory/WebServices/Proxy/Resource.cs @@ -0,0 +1,51 @@ +using System; +using System.CodeDom.Compiler; +using System.ServiceModel; +using System.ServiceModel.Channels; + +namespace Microsoft.ActiveDirectory.WebServices.Proxy +{ + // Token: 0x0200004C RID: 76 + [GeneratedCode("System.ServiceModel", "3.0.0.0")] + [ServiceContract(Namespace = "http://schemas.xmlsoap.org/ws/2004/09/transfer", ConfigurationName = "Resource", SessionMode = SessionMode.Required)] + internal interface Resource + { + // Token: 0x06000180 RID: 384 + [OperationContract(Action = "http://schemas.xmlsoap.org/ws/2004/09/transfer/Get", ReplyAction = "http://schemas.xmlsoap.org/ws/2004/09/transfer/GetResponse")] + [FaultContract(typeof(FaultDetail), Action = "http://schemas.dmtf.org/wbem/wsman/1/wsman/fault", Name = "AccessDenied", Namespace = "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd")] + [FaultContract(typeof(FaultDetail1), Action = "http://schemas.dmtf.org/wbem/wsman/1/wsman/fault", Name = "EncodingLimit", Namespace = "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd")] + [FaultContract(typeof(FaultDetail), Action = "http://schemas.microsoft.com/2006/11/IdentityManagement/DirectoryAccess/fault", Name = "UnwillingToPerform", Namespace = "http://schemas.microsoft.com/2006/11/IdentityManagement/DirectoryAccess")] + [FaultContract(typeof(FragmentDialect), Action = "http://schemas.dmtf.org/wbem/wsman/1/wsman/fault", Name = "FragmentDialectNotSupported", Namespace = "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd")] + [FaultContract(typeof(FaultDetail), Action = "http://schemas.xmlsoap.org/ws/2004/08/addressing/fault", Name = "EndpointUnavailable", Namespace = "http://schemas.xmlsoap.org/ws/2004/08/addressing")] + [FaultContract(typeof(AttributeTypeNotValid), Action = "http://schemas.dmtf.org/wbem/wsman/1/wsman/fault", Name = "CannotProcessFilter", Namespace = "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd")] + [FaultContract(typeof(FaultDetail), Action = "http://schemas.dmtf.org/wbem/wsman/1/wsman/fault", Name = "SchemaValidationError", Namespace = "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd")] + [FaultContract(typeof(FaultDetail), Action = "http://schemas.xmlsoap.org/ws/2004/08/addressing/fault", Name = "DestinationUnreachable", Namespace = "http://schemas.xmlsoap.org/ws/2004/08/addressing")] + [XmlSerializerFormat(SupportFaults = true)] + Message Get(Message request); + + // Token: 0x06000181 RID: 385 + [OperationContract(Action = "http://schemas.xmlsoap.org/ws/2004/09/transfer/Put", ReplyAction = "http://schemas.xmlsoap.org/ws/2004/09/transfer/PutResponse")] + [FaultContract(typeof(AttributeTypeNotValid), Action = "http://schemas.dmtf.org/wbem/wsman/1/wsman/fault", Name = "CannotProcessFilter", Namespace = "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd")] + [FaultContract(typeof(FaultDetail), Action = "http://schemas.dmtf.org/wbem/wsman/1/wsman/fault", Name = "AccessDenied", Namespace = "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd")] + [FaultContract(typeof(FaultDetail), Action = "http://schemas.xmlsoap.org/ws/2004/08/addressing/fault", Name = "DestinationUnreachable", Namespace = "http://schemas.xmlsoap.org/ws/2004/08/addressing")] + [FaultContract(typeof(FaultDetail1), Action = "http://schemas.dmtf.org/wbem/wsman/1/wsman/fault", Name = "EncodingLimit", Namespace = "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd")] + [FaultContract(typeof(FaultDetail), Action = "http://schemas.microsoft.com/2006/11/IdentityManagement/DirectoryAccess/fault", Name = "UnwillingToPerform", Namespace = "http://schemas.microsoft.com/2006/11/IdentityManagement/DirectoryAccess")] + [FaultContract(typeof(FragmentDialect), Action = "http://schemas.dmtf.org/wbem/wsman/1/wsman/fault", Name = "FragmentDialectNotSupported", Namespace = "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd")] + [FaultContract(typeof(FaultDetail), Action = "http://schemas.xmlsoap.org/ws/2004/08/addressing/fault", Name = "EndpointUnavailable", Namespace = "http://schemas.xmlsoap.org/ws/2004/08/addressing")] + [FaultContract(typeof(FaultDetail), Action = "http://schemas.xmlsoap.org/ws/2004/09/transfer/fault", Name = "InvalidRepresentation")] + [FaultContract(typeof(FaultDetail), Action = "http://schemas.dmtf.org/wbem/wsman/1/wsman/fault", Name = "SchemaValidationError", Namespace = "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd")] + [FaultContract(typeof(FaultDetail), Action = "http://schemas.xmlsoap.org/ws/2004/08/addressing/fault", Name = "ActionNotSupportedFault", Namespace = "http://schemas.xmlsoap.org/ws/2004/08/addressing")] + [XmlSerializerFormat(SupportFaults = true)] + Message Put(Message request); + + // Token: 0x06000182 RID: 386 + [OperationContract(Action = "http://schemas.xmlsoap.org/ws/2004/09/transfer/Delete", ReplyAction = "http://schemas.xmlsoap.org/ws/2004/09/transfer/DeleteResponse")] + [FaultContract(typeof(FaultDetail), Action = "http://schemas.xmlsoap.org/ws/2004/08/addressing/fault", Name = "EndpointUnavailable", Namespace = "http://schemas.xmlsoap.org/ws/2004/08/addressing")] + [FaultContract(typeof(FaultDetail), Action = "http://schemas.xmlsoap.org/ws/2004/08/addressing/fault", Name = "DestinationUnreachable", Namespace = "http://schemas.xmlsoap.org/ws/2004/08/addressing")] + [FaultContract(typeof(FaultDetail), Action = "http://schemas.dmtf.org/wbem/wsman/1/wsman/fault", Name = "SchemaValidationError", Namespace = "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd")] + [FaultContract(typeof(FaultDetail), Action = "http://schemas.dmtf.org/wbem/wsman/1/wsman/fault", Name = "AccessDenied", Namespace = "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd")] + [FaultContract(typeof(FaultDetail), Action = "http://schemas.microsoft.com/2006/11/IdentityManagement/DirectoryAccess/fault", Name = "UnwillingToPerform", Namespace = "http://schemas.microsoft.com/2006/11/IdentityManagement/DirectoryAccess")] + [XmlSerializerFormat(SupportFaults = true)] + Message Delete(Message request); + } +} diff --git a/SnaffCore/ActiveDirectory/WebServices/Proxy/ResourceChannel.cs b/SnaffCore/ActiveDirectory/WebServices/Proxy/ResourceChannel.cs new file mode 100644 index 00000000..dca93ea7 --- /dev/null +++ b/SnaffCore/ActiveDirectory/WebServices/Proxy/ResourceChannel.cs @@ -0,0 +1,13 @@ +using System; +using System.CodeDom.Compiler; +using System.ServiceModel; +using System.ServiceModel.Channels; + +namespace Microsoft.ActiveDirectory.WebServices.Proxy +{ + // Token: 0x0200004D RID: 77 + [GeneratedCode("System.ServiceModel", "3.0.0.0")] + internal interface ResourceChannel : Resource, IClientChannel, IContextChannel, IChannel, ICommunicationObject, IExtensibleObject, IDisposable + { + } +} diff --git a/SnaffCore/ActiveDirectory/WebServices/Proxy/ResourceClient.cs b/SnaffCore/ActiveDirectory/WebServices/Proxy/ResourceClient.cs new file mode 100644 index 00000000..3d36d07f --- /dev/null +++ b/SnaffCore/ActiveDirectory/WebServices/Proxy/ResourceClient.cs @@ -0,0 +1,61 @@ +using System; +using System.CodeDom.Compiler; +using System.Diagnostics; +using System.ServiceModel; +using System.ServiceModel.Channels; + +namespace Microsoft.ActiveDirectory.WebServices.Proxy +{ + // Token: 0x0200004E RID: 78 + [DebuggerStepThrough] + [GeneratedCode("System.ServiceModel", "3.0.0.0")] + internal class ResourceClient : ClientBase, Resource + { + // Token: 0x06000183 RID: 387 RVA: 0x000030AF File Offset: 0x000012AF + public ResourceClient() + { + } + + // Token: 0x06000184 RID: 388 RVA: 0x000030B7 File Offset: 0x000012B7 + public ResourceClient(string endpointConfigurationName) + : base(endpointConfigurationName) + { + } + + // Token: 0x06000185 RID: 389 RVA: 0x000030C0 File Offset: 0x000012C0 + public ResourceClient(string endpointConfigurationName, string remoteAddress) + : base(endpointConfigurationName, remoteAddress) + { + } + + // Token: 0x06000186 RID: 390 RVA: 0x000030CA File Offset: 0x000012CA + public ResourceClient(string endpointConfigurationName, EndpointAddress remoteAddress) + : base(endpointConfigurationName, remoteAddress) + { + } + + // Token: 0x06000187 RID: 391 RVA: 0x000030D4 File Offset: 0x000012D4 + public ResourceClient(Binding binding, EndpointAddress remoteAddress) + : base(binding, remoteAddress) + { + } + + // Token: 0x06000188 RID: 392 RVA: 0x000030DE File Offset: 0x000012DE + public Message Get(Message request) + { + return base.Channel.Get(request); + } + + // Token: 0x06000189 RID: 393 RVA: 0x000030EC File Offset: 0x000012EC + public Message Put(Message request) + { + return base.Channel.Put(request); + } + + // Token: 0x0600018A RID: 394 RVA: 0x000030FA File Offset: 0x000012FA + public Message Delete(Message request) + { + return base.Channel.Delete(request); + } + } +} diff --git a/SnaffCore/ActiveDirectory/WebServices/Proxy/ResourceFactory.cs b/SnaffCore/ActiveDirectory/WebServices/Proxy/ResourceFactory.cs new file mode 100644 index 00000000..9e88951c --- /dev/null +++ b/SnaffCore/ActiveDirectory/WebServices/Proxy/ResourceFactory.cs @@ -0,0 +1,29 @@ +using System; +using System.CodeDom.Compiler; +using System.ServiceModel; +using System.ServiceModel.Channels; + +namespace Microsoft.ActiveDirectory.WebServices.Proxy +{ + // Token: 0x0200004F RID: 79 + [GeneratedCode("System.ServiceModel", "3.0.0.0")] + [ServiceContract(Namespace = "http://schemas.xmlsoap.org/ws/2004/09/transfer", ConfigurationName = "ResourceFactory", SessionMode = SessionMode.Required)] + internal interface ResourceFactory + { + // Token: 0x0600018B RID: 395 + [OperationContract(Action = "http://schemas.xmlsoap.org/ws/2004/09/transfer/Create", ReplyAction = "http://schemas.xmlsoap.org/ws/2004/09/transfer/CreateResponse")] + [FaultContract(typeof(FaultDetail1), Action = "http://schemas.dmtf.org/wbem/wsman/1/wsman/fault", Name = "EncodingLimit", Namespace = "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd")] + [FaultContract(typeof(FaultDetail), Action = "http://schemas.xmlsoap.org/ws/2004/08/addressing/fault", Name = "DestinationUnreachable", Namespace = "http://schemas.xmlsoap.org/ws/2004/08/addressing")] + [FaultContract(typeof(FaultDetail), Action = "http://schemas.dmtf.org/wbem/wsman/1/wsman/fault", Name = "AlreadyExists", Namespace = "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd")] + [FaultContract(typeof(FaultDetail), Action = "http://schemas.dmtf.org/wbem/wsman/1/wsman/fault", Name = "SchemaValidationError", Namespace = "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd")] + [FaultContract(typeof(AttributeTypeNotValid), Action = "http://schemas.dmtf.org/wbem/wsman/1/wsman/fault", Name = "CannotProcessFilter", Namespace = "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd")] + [FaultContract(typeof(FaultDetail), Action = "http://schemas.xmlsoap.org/ws/2004/08/addressing/fault", Name = "EndpointUnavailable", Namespace = "http://schemas.xmlsoap.org/ws/2004/08/addressing")] + [FaultContract(typeof(FaultDetail), Action = "http://schemas.xmlsoap.org/ws/2004/08/addressing/fault", Name = "ActionNotSupportedFault", Namespace = "http://schemas.xmlsoap.org/ws/2004/08/addressing")] + [FaultContract(typeof(FaultDetail), Action = "http://schemas.xmlsoap.org/ws/2004/09/transfer/fault", Name = "InvalidRepresentation")] + [FaultContract(typeof(FragmentDialect), Action = "http://schemas.dmtf.org/wbem/wsman/1/wsman/fault", Name = "FragmentDialectNotSupported", Namespace = "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd")] + [FaultContract(typeof(FaultDetail), Action = "http://schemas.dmtf.org/wbem/wsman/1/wsman/fault", Name = "AccessDenied", Namespace = "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd")] + [FaultContract(typeof(FaultDetail), Action = "http://schemas.microsoft.com/2006/11/IdentityManagement/DirectoryAccess/fault", Name = "UnwillingToPerform", Namespace = "http://schemas.microsoft.com/2006/11/IdentityManagement/DirectoryAccess")] + [XmlSerializerFormat(SupportFaults = true)] + Message Create(Message request); + } +} diff --git a/SnaffCore/ActiveDirectory/WebServices/Proxy/ResourceFactoryChannel.cs b/SnaffCore/ActiveDirectory/WebServices/Proxy/ResourceFactoryChannel.cs new file mode 100644 index 00000000..9b01621e --- /dev/null +++ b/SnaffCore/ActiveDirectory/WebServices/Proxy/ResourceFactoryChannel.cs @@ -0,0 +1,13 @@ +using System; +using System.CodeDom.Compiler; +using System.ServiceModel; +using System.ServiceModel.Channels; + +namespace Microsoft.ActiveDirectory.WebServices.Proxy +{ + // Token: 0x02000050 RID: 80 + [GeneratedCode("System.ServiceModel", "3.0.0.0")] + internal interface ResourceFactoryChannel : ResourceFactory, IClientChannel, IContextChannel, IChannel, ICommunicationObject, IExtensibleObject, IDisposable + { + } +} diff --git a/SnaffCore/ActiveDirectory/WebServices/Proxy/ResourceFactoryClient.cs b/SnaffCore/ActiveDirectory/WebServices/Proxy/ResourceFactoryClient.cs new file mode 100644 index 00000000..7f9fed49 --- /dev/null +++ b/SnaffCore/ActiveDirectory/WebServices/Proxy/ResourceFactoryClient.cs @@ -0,0 +1,49 @@ +using System; +using System.CodeDom.Compiler; +using System.Diagnostics; +using System.ServiceModel; +using System.ServiceModel.Channels; + +namespace Microsoft.ActiveDirectory.WebServices.Proxy +{ + // Token: 0x02000051 RID: 81 + [DebuggerStepThrough] + [GeneratedCode("System.ServiceModel", "3.0.0.0")] + internal class ResourceFactoryClient : ClientBase, ResourceFactory + { + // Token: 0x0600018C RID: 396 RVA: 0x00003108 File Offset: 0x00001308 + public ResourceFactoryClient() + { + } + + // Token: 0x0600018D RID: 397 RVA: 0x00003110 File Offset: 0x00001310 + public ResourceFactoryClient(string endpointConfigurationName) + : base(endpointConfigurationName) + { + } + + // Token: 0x0600018E RID: 398 RVA: 0x00003119 File Offset: 0x00001319 + public ResourceFactoryClient(string endpointConfigurationName, string remoteAddress) + : base(endpointConfigurationName, remoteAddress) + { + } + + // Token: 0x0600018F RID: 399 RVA: 0x00003123 File Offset: 0x00001323 + public ResourceFactoryClient(string endpointConfigurationName, EndpointAddress remoteAddress) + : base(endpointConfigurationName, remoteAddress) + { + } + + // Token: 0x06000190 RID: 400 RVA: 0x0000312D File Offset: 0x0000132D + public ResourceFactoryClient(Binding binding, EndpointAddress remoteAddress) + : base(binding, remoteAddress) + { + } + + // Token: 0x06000191 RID: 401 RVA: 0x00003137 File Offset: 0x00001337 + public Message Create(Message request) + { + return base.Channel.Create(request); + } + } +} diff --git a/SnaffCore/ActiveDirectory/WebServices/Proxy/Search.cs b/SnaffCore/ActiveDirectory/WebServices/Proxy/Search.cs new file mode 100644 index 00000000..0a1f4451 --- /dev/null +++ b/SnaffCore/ActiveDirectory/WebServices/Proxy/Search.cs @@ -0,0 +1,59 @@ +using System; +using System.CodeDom.Compiler; +using System.ServiceModel; +using System.ServiceModel.Channels; + +namespace Microsoft.ActiveDirectory.WebServices.Proxy +{ + // Token: 0x02000052 RID: 82 + [GeneratedCode("System.ServiceModel", "3.0.0.0")] + [ServiceContract(Namespace = "http://schemas.xmlsoap.org/ws/2004/09/enumeration", ConfigurationName = "Search", SessionMode = SessionMode.Required)] + internal interface Search + { + // Token: 0x06000192 RID: 402 + [OperationContract(Action = "http://schemas.xmlsoap.org/ws/2004/09/enumeration/Enumerate", ReplyAction = "http://schemas.xmlsoap.org/ws/2004/09/enumeration/EnumerateResponse")] + [FaultContract(typeof(EnumerateFault), Action = "http://schemas.microsoft.com/2008/1/ActiveDirectory/Data/fault", Name = "InvalidSortKey", Namespace = "http://schemas.microsoft.com/2008/1/ActiveDirectory")] + [FaultContract(typeof(EnumerateFault), Action = "http://schemas.microsoft.com/2008/1/ActiveDirectory/Data/fault", Name = "InvalidPropertyFault", Namespace = "http://schemas.microsoft.com/2008/1/ActiveDirectory")] + [FaultContract(typeof(SupportedSelectOrSortDialect), Action = "http://schemas.microsoft.com/2008/1/ActiveDirectory/Data/fault", Name = "UnsupportedSelectOrSortDialectFault", Namespace = "http://schemas.microsoft.com/2008/1/ActiveDirectory")] + [FaultContract(typeof(EnumerateFault), Action = "http://schemas.microsoft.com/2008/1/ActiveDirectory/Data/fault", Name = "EnumerationContextLimitExceeded", Namespace = "http://schemas.microsoft.com/2008/1/ActiveDirectory")] + [FaultContract(typeof(EnumerateFault), Action = "http://schemas.xmlsoap.org/ws/2004/09/enumeration/fault", Name = "CannotProcessFilter")] + [FaultContract(typeof(SupportedDialect), Action = "http://schemas.xmlsoap.org/ws/2004/09/enumeration/fault", Name = "FilterDialectRequestedUnavailable")] + [FaultContract(typeof(EnumerateFault), Action = "http://schemas.xmlsoap.org/ws/2004/09/enumeration/fault", Name = "InvalidExpirationTime")] + [FaultContract(typeof(FaultDetail), Action = "http://schemas.xmlsoap.org/ws/2004/08/addressing/fault", Name = "DestinationUnreachable", Namespace = "http://schemas.xmlsoap.org/ws/2004/08/addressing")] + [FaultContract(typeof(FaultDetail), Action = "http://schemas.xmlsoap.org/ws/2004/08/addressing/fault", Name = "EndpointUnavailable", Namespace = "http://schemas.xmlsoap.org/ws/2004/08/addressing")] + [XmlSerializerFormat(SupportFaults = true)] + Message Enumerate(Message request); + + // Token: 0x06000193 RID: 403 + [OperationContract(Action = "http://schemas.xmlsoap.org/ws/2004/09/enumeration/Pull", ReplyAction = "http://schemas.xmlsoap.org/ws/2004/09/enumeration/PullResponse")] + [FaultContract(typeof(PullFault), Action = "http://schemas.xmlsoap.org/ws/2004/09/enumeration/fault", Name = "TimedOut")] + [FaultContract(typeof(FaultDetail), Action = "http://schemas.xmlsoap.org/ws/2004/08/addressing/fault", Name = "EndpointUnavailable", Namespace = "http://schemas.xmlsoap.org/ws/2004/08/addressing")] + [FaultContract(typeof(PullFault), Action = "http://schemas.microsoft.com/2008/1/ActiveDirectory/Data/fault", Name = "MaxCharsNotSupported", Namespace = "http://schemas.microsoft.com/2008/1/ActiveDirectory")] + [FaultContract(typeof(FaultDetail), Action = "http://schemas.xmlsoap.org/ws/2004/08/addressing/fault", Name = "DestinationUnreachable", Namespace = "http://schemas.xmlsoap.org/ws/2004/08/addressing")] + [FaultContract(typeof(FaultDetail), Action = "http://schemas.xmlsoap.org/ws/2004/09/enumeration/fault", Name = "InvalidEnumerationContext")] + [FaultContract(typeof(PullFault), Action = "http://schemas.microsoft.com/2008/1/ActiveDirectory/Data/fault", Name = "MaxTimeExceedsLimit", Namespace = "http://schemas.microsoft.com/2008/1/ActiveDirectory")] + [XmlSerializerFormat(SupportFaults = true)] + Message Pull(Message request); + + // Token: 0x06000194 RID: 404 + [OperationContract(Action = "http://schemas.xmlsoap.org/ws/2004/09/enumeration/Renew", ReplyAction = "http://schemas.xmlsoap.org/ws/2004/09/enumeration/RenewResponse")] + [FaultContract(typeof(FaultDetail), Action = "http://schemas.xmlsoap.org/ws/2004/08/addressing/fault", Name = "EndpointUnavailable", Namespace = "http://schemas.xmlsoap.org/ws/2004/08/addressing")] + [FaultContract(typeof(RenewFault), Action = "http://schemas.xmlsoap.org/ws/2004/09/enumeration/fault", Name = "UnableToRenew")] + [FaultContract(typeof(FaultDetail), Action = "http://schemas.xmlsoap.org/ws/2004/09/enumeration/fault", Name = "InvalidEnumerationContext")] + [XmlSerializerFormat(SupportFaults = true)] + Message Renew(Message request); + + // Token: 0x06000195 RID: 405 + [OperationContract(Action = "http://schemas.xmlsoap.org/ws/2004/09/enumeration/GetStatus", ReplyAction = "http://schemas.xmlsoap.org/ws/2004/09/enumeration/GetStatusResponse")] + [FaultContract(typeof(FaultDetail), Action = "http://schemas.xmlsoap.org/ws/2004/08/addressing/fault", Name = "EndpointUnavailable", Namespace = "http://schemas.xmlsoap.org/ws/2004/08/addressing")] + [FaultContract(typeof(FaultDetail), Action = "http://schemas.xmlsoap.org/ws/2004/09/enumeration/fault", Name = "InvalidEnumerationContext")] + [XmlSerializerFormat(SupportFaults = true)] + Message GetStatus(Message request); + + // Token: 0x06000196 RID: 406 + [OperationContract(Action = "http://schemas.xmlsoap.org/ws/2004/09/enumeration/Release", ReplyAction = "http://schemas.xmlsoap.org/ws/2004/09/enumeration/ReleaseResponse")] + [FaultContract(typeof(FaultDetail), Action = "http://schemas.xmlsoap.org/ws/2004/08/addressing/fault", Name = "EndpointUnavailable", Namespace = "http://schemas.xmlsoap.org/ws/2004/08/addressing")] + [XmlSerializerFormat(SupportFaults = true)] + Message Release(Message request); + } +} diff --git a/SnaffCore/ActiveDirectory/WebServices/Proxy/SearchChannel.cs b/SnaffCore/ActiveDirectory/WebServices/Proxy/SearchChannel.cs new file mode 100644 index 00000000..0211478c --- /dev/null +++ b/SnaffCore/ActiveDirectory/WebServices/Proxy/SearchChannel.cs @@ -0,0 +1,13 @@ +using System; +using System.CodeDom.Compiler; +using System.ServiceModel; +using System.ServiceModel.Channels; + +namespace Microsoft.ActiveDirectory.WebServices.Proxy +{ + // Token: 0x02000053 RID: 83 + [GeneratedCode("System.ServiceModel", "3.0.0.0")] + internal interface SearchChannel : Search, IClientChannel, IContextChannel, IChannel, ICommunicationObject, IExtensibleObject, IDisposable + { + } +} diff --git a/SnaffCore/ActiveDirectory/WebServices/Proxy/SearchClient.cs b/SnaffCore/ActiveDirectory/WebServices/Proxy/SearchClient.cs new file mode 100644 index 00000000..5c2eab76 --- /dev/null +++ b/SnaffCore/ActiveDirectory/WebServices/Proxy/SearchClient.cs @@ -0,0 +1,73 @@ +using System; +using System.CodeDom.Compiler; +using System.Diagnostics; +using System.ServiceModel; +using System.ServiceModel.Channels; + +namespace Microsoft.ActiveDirectory.WebServices.Proxy +{ + // Token: 0x02000054 RID: 84 + [DebuggerStepThrough] + [GeneratedCode("System.ServiceModel", "3.0.0.0")] + internal class SearchClient : ClientBase, Search + { + // Token: 0x06000197 RID: 407 RVA: 0x00003145 File Offset: 0x00001345 + public SearchClient() + { + } + + // Token: 0x06000198 RID: 408 RVA: 0x0000314D File Offset: 0x0000134D + public SearchClient(string endpointConfigurationName) + : base(endpointConfigurationName) + { + } + + // Token: 0x06000199 RID: 409 RVA: 0x00003156 File Offset: 0x00001356 + public SearchClient(string endpointConfigurationName, string remoteAddress) + : base(endpointConfigurationName, remoteAddress) + { + } + + // Token: 0x0600019A RID: 410 RVA: 0x00003160 File Offset: 0x00001360 + public SearchClient(string endpointConfigurationName, EndpointAddress remoteAddress) + : base(endpointConfigurationName, remoteAddress) + { + } + + // Token: 0x0600019B RID: 411 RVA: 0x0000316A File Offset: 0x0000136A + public SearchClient(Binding binding, EndpointAddress remoteAddress) + : base(binding, remoteAddress) + { + } + + // Token: 0x0600019C RID: 412 RVA: 0x00003174 File Offset: 0x00001374 + public Message Enumerate(Message request) + { + return base.Channel.Enumerate(request); + } + + // Token: 0x0600019D RID: 413 RVA: 0x00003182 File Offset: 0x00001382 + public Message Pull(Message request) + { + return base.Channel.Pull(request); + } + + // Token: 0x0600019E RID: 414 RVA: 0x00003190 File Offset: 0x00001390 + public Message Renew(Message request) + { + return base.Channel.Renew(request); + } + + // Token: 0x0600019F RID: 415 RVA: 0x0000319E File Offset: 0x0000139E + public Message GetStatus(Message request) + { + return base.Channel.GetStatus(request); + } + + // Token: 0x060001A0 RID: 416 RVA: 0x000031AC File Offset: 0x000013AC + public Message Release(Message request) + { + return base.Channel.Release(request); + } + } +} diff --git a/SnaffCore/ActiveDirectory/WebServices/Proxy/SupportedDialect.cs b/SnaffCore/ActiveDirectory/WebServices/Proxy/SupportedDialect.cs new file mode 100644 index 00000000..1cff0005 --- /dev/null +++ b/SnaffCore/ActiveDirectory/WebServices/Proxy/SupportedDialect.cs @@ -0,0 +1,37 @@ +using System; +using System.CodeDom.Compiler; +using System.ComponentModel; +using System.Diagnostics; +using System.Xml.Serialization; + +namespace Microsoft.ActiveDirectory.WebServices.Proxy +{ + // Token: 0x0200004B RID: 75 + [GeneratedCode("svcutil", "3.0.4506.2123")] + [DebuggerStepThrough] + [DesignerCategory("code")] + [XmlType(Namespace = "http://schemas.xmlsoap.org/ws/2004/09/enumeration")] + [XmlRoot(Namespace = "http://schemas.xmlsoap.org/ws/2004/09/enumeration")] + [Serializable] + public class SupportedDialect + { + // Token: 0x1700007E RID: 126 + // (get) Token: 0x0600017D RID: 381 RVA: 0x00003096 File Offset: 0x00001296 + // (set) Token: 0x0600017E RID: 382 RVA: 0x0000309E File Offset: 0x0000129E + [XmlText(DataType = "anyURI")] + public string Value + { + get + { + return this.valueField; + } + set + { + this.valueField = value; + } + } + + // Token: 0x040001FF RID: 511 + private string valueField; + } +} diff --git a/SnaffCore/ActiveDirectory/WebServices/Proxy/SupportedSelectOrSortDialect.cs b/SnaffCore/ActiveDirectory/WebServices/Proxy/SupportedSelectOrSortDialect.cs new file mode 100644 index 00000000..0a4cda78 --- /dev/null +++ b/SnaffCore/ActiveDirectory/WebServices/Proxy/SupportedSelectOrSortDialect.cs @@ -0,0 +1,37 @@ +using System; +using System.CodeDom.Compiler; +using System.ComponentModel; +using System.Diagnostics; +using System.Xml.Serialization; + +namespace Microsoft.ActiveDirectory.WebServices.Proxy +{ + // Token: 0x0200004A RID: 74 + [GeneratedCode("svcutil", "3.0.4506.2123")] + [DebuggerStepThrough] + [DesignerCategory("code")] + [XmlType(Namespace = "http://schemas.microsoft.com/2008/1/ActiveDirectory")] + [XmlRoot(Namespace = "http://schemas.microsoft.com/2008/1/ActiveDirectory")] + [Serializable] + public class SupportedSelectOrSortDialect + { + // Token: 0x1700007D RID: 125 + // (get) Token: 0x0600017A RID: 378 RVA: 0x0000307D File Offset: 0x0000127D + // (set) Token: 0x0600017B RID: 379 RVA: 0x00003085 File Offset: 0x00001285 + [XmlText(DataType = "anyURI")] + public string Value + { + get + { + return this.valueField; + } + set + { + this.valueField = value; + } + } + + // Token: 0x040001FE RID: 510 + private string valueField; + } +} diff --git a/SnaffCore/Config/Options.cs b/SnaffCore/Config/Options.cs index 78c66282..e886fbc6 100644 --- a/SnaffCore/Config/Options.cs +++ b/SnaffCore/Config/Options.cs @@ -52,11 +52,12 @@ public partial class Options public bool LogToConsole { get; set; } = true; public string LogLevelString { get; set; } = "info"; + public bool ADWS { get; set; } = false; // ShareFinder Options public bool ShareFinderEnabled { get; set; } = true; public string TargetDomain { get; set; } public string TargetDc { get; set; } - public bool LogDeniedShares { get; set; } = false; + public bool LogDeniedShares { get; set; } = false; // FileScanner Options public bool DomainUserRules { get; set; } = false; @@ -109,7 +110,7 @@ public partial class Options "configmgr" }; - public List DomainUserStrictStrings { get; set; } + public List DomainUserStrictStrings { get; set; } public List DomainUsersWordlistRules { get; set; } = new List() { diff --git a/SnaffCore/SnaffCon.cs b/SnaffCore/SnaffCon.cs index 5334939d..6acf22ee 100644 --- a/SnaffCore/SnaffCon.cs +++ b/SnaffCore/SnaffCon.cs @@ -1,22 +1,26 @@ -using SnaffCore.Classifiers; using SnaffCore.ActiveDirectory; +using SnaffCore.ADWS; +using SnaffCore.ADWS.Enumeration; +using SnaffCore.Classifiers; using SnaffCore.Concurrency; using SnaffCore.Config; +using SnaffCore.FileScan; using SnaffCore.ShareFind; using SnaffCore.TreeWalk; -using SnaffCore.FileScan; using System; using System.Collections.Generic; using System.Diagnostics; +using System.DirectoryServices.ActiveDirectory; using System.Linq; +using System.Net; +using System.Net.NetworkInformation; +using System.Security.Cryptography; using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Timers; using static SnaffCore.Config.Options; using Timer = System.Timers.Timer; -using System.Net; - namespace SnaffCore { public class SnaffCon @@ -28,7 +32,7 @@ public class SnaffCon private static BlockingStaticTaskScheduler ShareTaskScheduler; private static BlockingStaticTaskScheduler TreeTaskScheduler; private static BlockingStaticTaskScheduler FileTaskScheduler; - + private static ShareFinder ShareFinder; private static TreeWalker TreeWalker; private static FileScanner FileScanner; @@ -94,7 +98,7 @@ public void Execute() // If we want to hunt for user IDs, we need data from the running user's domain. // Future - walk trusts - if ( MyOptions.DomainUserRules) + if (MyOptions.DomainUserRules) { DomainUserDiscovery(); } @@ -176,12 +180,16 @@ private void DomainDfsDiscovery() } } + private static string GetCurrentDomain() + { + return IPGlobalProperties.GetIPGlobalProperties().DomainName; + } private void DomainTargetDiscovery() { List targetComputers; // Give preference to explicit targets in the options file over LDAP computer discovery - if (MyOptions.ComputerTargets != null) + if (MyOptions.ComputerTargets != null) { Mq.Info("Using computer list from user-specified options."); @@ -197,9 +205,40 @@ private void DomainTargetDiscovery() // We do this single threaded cos it's fast and not easily divisible. Mq.Info("Getting computers from AD."); - _adData.SetDomainComputers(MyOptions.ComputerTargetsLdapFilter); + if (MyOptions.ADWS) + { + targetComputers = new List(); + NetworkCredential Credential = null; + string domain = MyOptions.TargetDomain; + if (String.IsNullOrEmpty(domain)) + { + domain = GetCurrentDomain(); + } + ADWSConnection adwsConnection = new ADWSConnection(domain, "ldap:389", Credential); + EnumerateRequest enumerateRequest = new EnumerateRequest(adwsConnection); + List userObjects = enumerateRequest.Enumerate("(objectClass=computer)", adwsConnection.DefaultNamingContext, "subtree", new string[] { "DNSHostName" }); + foreach (ADObject userObject in userObjects) + { + if (userObject.Class == "computer" && !(String.IsNullOrEmpty(userObject.DNSHostName))) + { + string DNSHostName = userObject.DNSHostName; + if (!(DNSHostName.ToLower().Contains(domain))) + { + DNSHostName += "." + domain; + } + targetComputers.Add(DNSHostName); + } + } + + } + else + { + _adData.SetDomainComputers(MyOptions.ComputerTargetsLdapFilter); + + targetComputers = _adData.GetDomainComputers(); + } + - targetComputers = _adData.GetDomainComputers(); Mq.Info(string.Format("Got {0} computers from AD.", targetComputers.Count)); // if we're only scanning DFS shares then we can skip the SMB sharefinder and work from the list in AD, then jump to FileDiscovery(). @@ -356,7 +395,8 @@ private bool CheckExclusions(string computer) return true; } } - else { + else + { try { // resolve it @@ -371,7 +411,8 @@ private bool CheckExclusions(string computer) // exclude it return true; - }; + } + ; } } catch (Exception ex) diff --git a/SnaffCore/SnaffCore.csproj b/SnaffCore/SnaffCore.csproj index fa0fc804..8b475655 100644 --- a/SnaffCore/SnaffCore.csproj +++ b/SnaffCore/SnaffCore.csproj @@ -54,10 +54,14 @@ + + + + @@ -65,6 +69,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -83,6 +142,20 @@ + + + + + + + + + + + + + + @@ -94,5 +167,8 @@ 0.15.0 + + + \ No newline at end of file diff --git a/SnaffCore/dsinternals.common/Data/DNWithBinary.cs b/SnaffCore/dsinternals.common/Data/DNWithBinary.cs new file mode 100644 index 00000000..a34c3487 --- /dev/null +++ b/SnaffCore/dsinternals.common/Data/DNWithBinary.cs @@ -0,0 +1,62 @@ +namespace DSInternals.Common.Data +{ + using System; + using DSInternals.Common.Properties; + + /// + /// The DNWithBinary class represents the DN-Binary LDAP attribute syntax, which contains a binary value and a distinguished name (DN). + /// + public sealed class DNWithBinary + { + // String representation of DN-Binary data: B::: + private const string StringFormat = "B:{0}:{1}:{2}"; + private const string StringFormatPrefix = "B:"; + private const char StringFormatSeparator = ':'; + + public string DistinguishedName + { + get; + private set; + } + + public byte[] Binary + { + get; + private set; + } + + public DNWithBinary(string dn, byte[] binary) + { + Validator.AssertNotNullOrEmpty(dn, nameof(dn)); + Validator.AssertNotNull(binary, nameof(binary)); + + this.DistinguishedName = dn; + this.Binary = binary; + } + + public static DNWithBinary Parse(string dnWithBinary) + { + Validator.AssertNotNullOrEmpty(dnWithBinary, nameof(dnWithBinary)); + + bool hasCorrectPrefix = dnWithBinary.StartsWith(StringFormatPrefix); + int valueLeadingColonIndex = dnWithBinary.IndexOf(StringFormatSeparator, StringFormatPrefix.Length); + int valueTrailingColonIndex = dnWithBinary.IndexOf(StringFormatSeparator, valueLeadingColonIndex + 1); + bool has4Parts = valueLeadingColonIndex >= 3 && (valueLeadingColonIndex + 1) < valueTrailingColonIndex; + + if (!hasCorrectPrefix || !has4Parts) + { + // We do not need to perform a more thorough validation. + throw new ArgumentException(Resources.NotDNWithBinaryMessage, nameof(dnWithBinary)); + } + + string dn = dnWithBinary.Substring(valueTrailingColonIndex + 1); + byte[] binary = dnWithBinary.HexToBinary(valueLeadingColonIndex + 1, valueTrailingColonIndex - valueLeadingColonIndex - 1); + return new DNWithBinary(dn, binary); + } + + public override string ToString() + { + return String.Format(StringFormat, this.Binary.Length * 2, this.Binary.ToHex(true), this.DistinguishedName); + } + } +} diff --git a/SnaffCore/dsinternals.common/Data/Hello/CustomKeyInformation.cs b/SnaffCore/dsinternals.common/Data/Hello/CustomKeyInformation.cs new file mode 100644 index 00000000..94fd1f52 --- /dev/null +++ b/SnaffCore/dsinternals.common/Data/Hello/CustomKeyInformation.cs @@ -0,0 +1,186 @@ +namespace DSInternals.Common.Data +{ + using System; + using System.IO; + + /// + /// Represents the CUSTOM_KEY_INFORMATION structure. + /// + /// https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/701a55dc-d062-4032-a2da-dbdfc384c8cf + public class CustomKeyInformation + { + private const byte CurrentVersion = 1; + private const int ShortRepresentationSize = sizeof(byte) + sizeof(KeyFlags); // Version + KeyFlags + private const int ReservedSize = 10 * sizeof(byte); + + public byte Version + { + get; + private set; + } + + public KeyFlags Flags + { + get; + private set; + } + + public VolumeType? VolumeType + { + get; + private set; + } + + /// + /// Specifies whether the device associated with this credential supports notification. + /// + public bool? SupportsNotification + { + get; + private set; + } + + /// + /// Specifies the version of the File Encryption Key (FEK). + /// + public byte? FekKeyVersion + { + get; + private set; + } + + /// + /// Specifies the strength of the NGC key. + /// + public KeyStrength? Strength + { + get; + private set; + } + + /// + /// Reserved for future use. + /// + public byte[] Reserved + { + get; + private set; + } + + /// + /// Extended custom key information. + /// + public byte[] EncodedExtendedCKI + { + get; + private set; + } + + public CustomKeyInformation() : this(KeyFlags.None) + { + } + + public CustomKeyInformation(KeyFlags flags) + { + this.Version = CurrentVersion; + this.Flags = flags; + } + + public CustomKeyInformation(byte[] blob) + { + // Validate the input + Validator.AssertNotNull(blob, nameof(blob)); + Validator.AssertMinLength(blob, ShortRepresentationSize, nameof(blob)); + + using (var stream = new MemoryStream(blob, false)) + { + // An 8-bit unsigned integer that must be set to 1: + this.Version = (byte)stream.ReadByte(); + + // An 8-bit unsigned integer that specifies zero or more bit-flag values. + this.Flags = (KeyFlags)stream.ReadByte(); + + // Note: This structure has two possible representations. In the first representation, only the Version and Flags fields are present; in this case the structure has a total size of two bytes. In the second representation, all additional fields shown below are also present; in this case, the structure's total size is variable. Differentiating between the two representations must be inferred using only the total size. + if (stream.Position < stream.Length) + { + // An 8-bit unsigned integer that specifies one of the volume types. + this.VolumeType = (VolumeType)stream.ReadByte(); + } + + if(stream.Position < stream.Length) + { + // An 8-bit unsigned integer that specifies whether the device associated with this credential supports notification. + this.SupportsNotification = Convert.ToBoolean(stream.ReadByte()); + } + + if(stream.Position < stream.Length) + { + // An 8-bit unsigned integer that specifies the version of the File Encryption Key (FEK). This field must be set to 1. + this.FekKeyVersion = (byte)stream.ReadByte(); + } + + if (stream.Position < stream.Length) + { + // An 8-bit unsigned integer that specifies the strength of the NGC key. + this.Strength = (KeyStrength)stream.ReadByte(); + } + + if (stream.Position < stream.Length) + { + // 10 bytes reserved for future use. + // Note: With FIDO, Azure incorrectly puts here 9 bytes instead of 10. + int actualReservedSize = (int)Math.Min(ReservedSize, stream.Length - stream.Position); + this.Reserved = new byte[actualReservedSize]; + stream.Read(this.Reserved, 0, actualReservedSize); + } + + if(stream.Position < stream.Length) + { + // Extended custom key information. + this.EncodedExtendedCKI = stream.ReadToEnd(); + } + } + } + + public byte[] ToByteArray() + { + using(var stream = new MemoryStream()) + { + stream.WriteByte(this.Version); + stream.WriteByte((byte)this.Flags); + + if(this.VolumeType.HasValue) + { + stream.WriteByte((byte)this.VolumeType.Value); + } + + if (this.SupportsNotification.HasValue) + { + stream.WriteByte(Convert.ToByte(this.SupportsNotification.Value)); + } + + if(this.FekKeyVersion.HasValue) + { + stream.WriteByte(this.FekKeyVersion.Value); + } + + if (this.Strength.HasValue) + { + stream.WriteByte((byte)this.Strength.Value); + } + + if (this.Reserved != null) + { + stream.Write(this.Reserved, 0, Reserved.Length); + } + + if(this.EncodedExtendedCKI != null) + { + stream.Write(this.EncodedExtendedCKI, 0, this.EncodedExtendedCKI.Length); + } + + return stream.ToArray(); + } + } + } +} diff --git a/SnaffCore/dsinternals.common/Data/Hello/KeyCredential.cs b/SnaffCore/dsinternals.common/Data/Hello/KeyCredential.cs new file mode 100644 index 00000000..c4d01ef4 --- /dev/null +++ b/SnaffCore/dsinternals.common/Data/Hello/KeyCredential.cs @@ -0,0 +1,492 @@ +namespace DSInternals.Common.Data +{ + using System; + using System.IO; + using System.Security.Cryptography; + using System.Security.Cryptography.X509Certificates; + + /// + /// This class represents a single AD/AAD key credential. + /// + /// + /// In Active Directory, this structure is stored as the binary portion of the msDS-KeyCredentialLink DN-Binary attribute + /// in the KEYCREDENTIALLINK_BLOB format. + /// The Azure Active Directory Graph API represents this structure in JSON format. + /// + /// https://msdn.microsoft.com/en-us/library/mt220505.aspx + public class KeyCredential + { + /// + /// Minimum length of the structure. + /// + private const int MinLength = sizeof(uint); // Version + + /// + /// V0 structure alignment in bytes. + /// + private const ushort PackSize = 4; + + /// + /// Defines the version of the structure. + /// + public KeyCredentialVersion Version + { + get; + private set; + } + + /// + /// A SHA256 hash of the Value field of the RawKeyMaterial entry. + /// + /// + /// Version 1 keys had a guid in this field instead if a hash. + /// + public string Identifier + { + get; + private set; + } + + public bool IsWeak + { + get + { + var key = this.RSAPublicKey; + return key.HasValue && key.Value.IsWeakKey(); + } + } + + public KeyUsage Usage + { + get; + private set; + } + + public string LegacyUsage + { + get; + private set; + } + + public KeySource Source + { + get; + private set; + } + + /// + /// Key material of the credential. + /// + public byte[] RawKeyMaterial + { + get; + private set; + } + + public RSAParameters? RSAPublicKey + { + get + { + if(this.RawKeyMaterial == null) + { + return null; + } + + if(this.Usage == KeyUsage.NGC || this.Usage == KeyUsage.STK) + { + // The RSA public key can be stored in at least 3 different formats. + + if (this.RawKeyMaterial.IsBCryptRSAPublicKeyBlob()) + { + // This public key is in DER format. This is typically true for device/computer keys. + return this.RawKeyMaterial.ImportRSAPublicKeyBCrypt(); + } + else if(this.RawKeyMaterial.IsTPM20PublicKeyBlob()) + { + // This public key is encoded as PCP_KEY_BLOB_WIN8. This is typically true for device keys protected by TPM. + // The PCP_KEY_BLOB_WIN8 structure is not yet supported by DSInternals. + return null; + } + else if(this.RawKeyMaterial.IsDERPublicKeyBlob()) + { + // This public key is encoded as BCRYPT_RSAKEY_BLOB. This is typically true for user keys. + return this.RawKeyMaterial.ImportRSAPublicKeyDER(); + } + } + + // Other key usages probably do not contain any public keys. + return null; + } + } + + public string RSAModulus + { + get + { + var publicKey = this.RSAPublicKey; + return publicKey.HasValue ? Convert.ToBase64String(publicKey.Value.Modulus) : null; + } + } + + public CustomKeyInformation CustomKeyInfo + { + get; + private set; + } + + public Guid? DeviceId + { + get; + private set; + } + + /// + /// The approximate time this key was created. + /// + public DateTime CreationTime + { + get; + private set; + } + + /// + /// The approximate time this key was last used. + /// + public DateTime? LastLogonTime + { + get; + private set; + } + + /// + /// Distinguished name of the AD object (UPN in case of AAD objects) that holds this key credential. + /// + public string Owner + { + get; + // We need to update this property after JSON deserialization, so it is internal instead of private. + internal set; + } + + public KeyCredential(X509Certificate2 certificate, Guid? deviceId, string owner, DateTime? currentTime = null, bool isComputerKey = false) + { + Validator.AssertNotNull(certificate, nameof(certificate)); + + // Computer NGC keys are DER-encoded, while user NGC keys are encoded as BCRYPT_RSAKEY_BLOB. + byte[] publicKey = isComputerKey ? certificate.ExportRSAPublicKeyDER() : certificate.ExportRSAPublicKeyBCrypt(); + this.Initialize(publicKey, deviceId, owner, currentTime, isComputerKey); + } + + public KeyCredential(byte[] publicKey, Guid? deviceId, string owner, DateTime? currentTime = null, bool isComputerKey = false) + { + Validator.AssertNotNull(publicKey, nameof(publicKey)); + this.Initialize(publicKey, deviceId, owner, currentTime, isComputerKey); + } + + private void Initialize(byte[] publicKey, Guid? deviceId, string owner, DateTime? currentTime, bool isComputerKey) + { + // Prodess owner DN/UPN + Validator.AssertNotNullOrEmpty(owner, nameof(owner)); + this.Owner = owner; + + // Initialize the Key Credential based on requirements stated in MS-KPP Processing Details: + this.Version = KeyCredentialVersion.Version2; + this.Identifier = ComputeKeyIdentifier(publicKey, this.Version); + this.CreationTime = currentTime.HasValue ? currentTime.Value.ToUniversalTime() : DateTime.UtcNow; + this.RawKeyMaterial = publicKey; + this.Usage = KeyUsage.NGC; + this.Source = KeySource.AD; + this.DeviceId = deviceId; + + // Computer NGC keys have to meet some requirements to pass the validated write + // The CustomKeyInformation entry is not present. + // The KeyApproximateLastLogonTimeStamp entry is not present. + if (!isComputerKey) + { + this.LastLogonTime = this.CreationTime; + this.CustomKeyInfo = new CustomKeyInformation(KeyFlags.None); + } + } + + public KeyCredential(byte[] blob, string owner) + { + // Input validation + Validator.AssertNotNull(blob, nameof(blob)); + Validator.AssertMinLength(blob, MinLength, nameof(blob)); + Validator.AssertNotNullOrEmpty(owner, nameof(owner)); + + // Init + this.Owner = owner; + + // Parse binary input + using (var stream = new MemoryStream(blob, false)) + { + using (var reader = new BinaryReader(stream)) + { + this.Version = (KeyCredentialVersion) reader.ReadUInt32(); + + // Read all entries corresponding to the KEYCREDENTIALLINK_ENTRY structure: + do + { + // A 16-bit unsigned integer that specifies the length of the Value field. + ushort length = reader.ReadUInt16(); + + // An 8-bit unsigned integer that specifies the type of data that is stored in the Value field. + KeyCredentialEntryType entryType = (KeyCredentialEntryType) reader.ReadByte(); + + // A series of bytes whose size and meaning are defined by the Identifier field. + byte[] value = reader.ReadBytes(length); + + if(this.Version == KeyCredentialVersion.Version0) + { + // Data used to be aligned to 4B in this legacy format. + int paddingLength = (PackSize - length % PackSize) % PackSize; + reader.ReadBytes(paddingLength); + } + + // Now parse the value of the current entry based on its type: + switch (entryType) + { + case KeyCredentialEntryType.KeyID: + this.Identifier = ConvertFromBinaryIdentifier(value, this.Version); + break; + case KeyCredentialEntryType.KeyHash: + // We do not need to validate the integrity of the data by the hash + break; + case KeyCredentialEntryType.KeyMaterial: + this.RawKeyMaterial = value; + break; + case KeyCredentialEntryType.KeyUsage: + if(length == sizeof(byte)) + { + // This is apparently a V2 structure + this.Usage = (KeyUsage)value[0]; + } + else + { + // This is a legacy structure that contains a string-encoded key usage instead of enum. + this.LegacyUsage = System.Text.Encoding.UTF8.GetString(value); + } + break; + case KeyCredentialEntryType.KeySource: + this.Source = (KeySource)value[0]; + break; + case KeyCredentialEntryType.DeviceId: + this.DeviceId = new Guid(value); + break; + case KeyCredentialEntryType.CustomKeyInformation: + this.CustomKeyInfo = new CustomKeyInformation(value); + break; + case KeyCredentialEntryType.KeyApproximateLastLogonTimeStamp: + this.LastLogonTime = ConvertFromBinaryTime(value, this.Source, this.Version); + break; + case KeyCredentialEntryType.KeyCreationTime: + this.CreationTime = ConvertFromBinaryTime(value, this.Source, this.Version); + break; + default: + // Unknown entry type. We will just ignore it. + break; + } + } while (reader.BaseStream.Position != reader.BaseStream.Length); + } + } + } + + /// + /// This constructor is only used for JSON deserialization. + /// + private KeyCredential() + { + this.Source = KeySource.AzureAD; + this.Version = KeyCredentialVersion.Version2; + } + + public override string ToString() + { + return String.Format( + "Id: {0}, Source: {1}, Version: {2}, Usage: {3}, CreationTime: {4}", + this.Identifier, + this.Source, + this.Version, + this.Usage, + this.CreationTime); + } + + public byte[] ToByteArray() + { + // Note that we do not support the legacy V1 format. + + // Serialize properties 3-9 first, as property 2 must contain their hash: + byte[] binaryProperties; + using (var propertyStream = new MemoryStream()) + { + using (var propertyWriter = new BinaryWriter(propertyStream)) + { + // Key Material + propertyWriter.Write((ushort)this.RawKeyMaterial.Length); + propertyWriter.Write((byte)KeyCredentialEntryType.KeyMaterial); + propertyWriter.Write(this.RawKeyMaterial); + + // Key Usage + propertyWriter.Write((ushort)sizeof(KeyUsage)); + propertyWriter.Write((byte)KeyCredentialEntryType.KeyUsage); + propertyWriter.Write((byte)this.Usage); + + // Key Source + propertyWriter.Write((ushort)sizeof(KeySource)); + propertyWriter.Write((byte)KeyCredentialEntryType.KeySource); + propertyWriter.Write((byte)this.Source); + + // Device ID + if(this.DeviceId.HasValue) + { + byte[] binaryGuid = this.DeviceId.Value.ToByteArray(); + propertyWriter.Write((ushort)binaryGuid.Length); + propertyWriter.Write((byte)KeyCredentialEntryType.DeviceId); + propertyWriter.Write(binaryGuid); + } + + // Custom Key Information + if(this.CustomKeyInfo != null) + { + byte[] binaryKeyInfo = this.CustomKeyInfo.ToByteArray(); + propertyWriter.Write((ushort)binaryKeyInfo.Length); + propertyWriter.Write((byte)KeyCredentialEntryType.CustomKeyInformation); + propertyWriter.Write(binaryKeyInfo); + } + + // Last Logon Time + if(this.LastLogonTime.HasValue) + { + byte[] binaryLastLogonTime = ConvertToBinaryTime(this.LastLogonTime.Value, this.Source, this.Version); + propertyWriter.Write((ushort)binaryLastLogonTime.Length); + propertyWriter.Write((byte)KeyCredentialEntryType.KeyApproximateLastLogonTimeStamp); + propertyWriter.Write(binaryLastLogonTime); + } + + // Creation Time + byte[] binaryCreationTime = ConvertToBinaryTime(this.CreationTime, this.Source, this.Version); + propertyWriter.Write((ushort)binaryCreationTime.Length); + propertyWriter.Write((byte)KeyCredentialEntryType.KeyCreationTime); + propertyWriter.Write(binaryCreationTime); + } + binaryProperties = propertyStream.ToArray(); + } + + using (var blobStream = new MemoryStream()) + { + using (var blobWriter = new BinaryWriter(blobStream)) + { + // Version + blobWriter.Write((uint)this.Version); + + // Key Identifier + byte[] binaryKeyId = ConvertToBinaryIdentifier(this.Identifier, this.Version); + blobWriter.Write((ushort)binaryKeyId.Length); + blobWriter.Write((byte)KeyCredentialEntryType.KeyID); + blobWriter.Write(binaryKeyId); + + // Key Hash + byte[] keyHash = ComputeHash(binaryProperties); + blobWriter.Write((ushort)keyHash.Length); + blobWriter.Write((byte)KeyCredentialEntryType.KeyHash); + blobWriter.Write(keyHash); + + // Append the remaining entries + blobWriter.Write(binaryProperties); + } + return blobStream.ToArray(); + } + } + + public string ToDNWithBinary() + { + // This method should only be used when the owner is in the form of a Distinguished Name. + return new DNWithBinary(this.Owner, this.ToByteArray()).ToString(); + } + + public static KeyCredential ParseDNBinary(string dnWithBinary) + { + Validator.AssertNotNullOrEmpty(dnWithBinary, nameof(dnWithBinary)); + var parsed = DNWithBinary.Parse(dnWithBinary); + return new KeyCredential(parsed.Binary, parsed.DistinguishedName); + } + + private static DateTime ConvertFromBinaryTime(byte[] binaryTime, KeySource source, KeyCredentialVersion version) + { + long timeStamp = BitConverter.ToInt64(binaryTime, 0); + + // AD and AAD use a different time encoding. + switch (version) + { + case KeyCredentialVersion.Version0: + return new DateTime(timeStamp); + case KeyCredentialVersion.Version1: + return DateTime.FromBinary(timeStamp); + case KeyCredentialVersion.Version2: + default: + return source == KeySource.AD ? DateTime.FromFileTime(timeStamp) : DateTime.FromBinary(timeStamp); + } + } + + private static byte[] ConvertToBinaryTime(DateTime time, KeySource source, KeyCredentialVersion version) + { + long timeStamp; + switch (version) + { + case KeyCredentialVersion.Version0: + timeStamp = time.Ticks; + break; + case KeyCredentialVersion.Version1: + timeStamp = time.ToBinary(); + break; + case KeyCredentialVersion.Version2: + default: + timeStamp = source == KeySource.AD ? time.ToFileTime() : time.ToBinary(); + break; + } + + return BitConverter.GetBytes(timeStamp); + } + + private static byte[] ComputeHash(byte[] data) + { + using (var sha256 = new SHA256Managed()) + { + return sha256.ComputeHash(data); + } + } + + private static string ComputeKeyIdentifier(byte[] keyMaterial, KeyCredentialVersion version) + { + byte[] binaryId = ComputeHash(keyMaterial); + return ConvertFromBinaryIdentifier(binaryId, version); + } + + private static string ConvertFromBinaryIdentifier(byte[] binaryId, KeyCredentialVersion version) + { + switch (version) + { + case KeyCredentialVersion.Version0: + case KeyCredentialVersion.Version1: + return binaryId.ToHex(true); + case KeyCredentialVersion.Version2: + default: + return Convert.ToBase64String(binaryId); + } + } + + private static byte[] ConvertToBinaryIdentifier(string keyIdentifier, KeyCredentialVersion version) + { + switch (version) + { + case KeyCredentialVersion.Version0: + case KeyCredentialVersion.Version1: + return keyIdentifier.HexToBinary(); + case KeyCredentialVersion.Version2: + default: + return Convert.FromBase64String(keyIdentifier); + } + } + } +} diff --git a/SnaffCore/dsinternals.common/Data/Hello/KeyCredentialEntryType.cs b/SnaffCore/dsinternals.common/Data/Hello/KeyCredentialEntryType.cs new file mode 100644 index 00000000..95b6a183 --- /dev/null +++ b/SnaffCore/dsinternals.common/Data/Hello/KeyCredentialEntryType.cs @@ -0,0 +1,55 @@ +namespace DSInternals.Common.Data +{ + /// + /// Key Credential Link Entry Identifier + /// + /// Describes the data stored in the Value field. + /// https://msdn.microsoft.com/en-us/library/mt220499.aspx + public enum KeyCredentialEntryType : byte + { + /// + /// A SHA256 hash of the Value field of the KeyMaterial entry. + /// + KeyID = 0x01, + + /// + /// A SHA256 hash of all entries following this entry. + /// + KeyHash = 0x02, + + /// + /// Key material of the credential. + /// + KeyMaterial = 0x03, + + /// + /// Key Usage + /// + KeyUsage = 0x04, + + /// + /// Key Source + /// + KeySource = 0x05, + + /// + /// Device Identifier + /// + DeviceId = 0x06, + + /// + /// Custom key information. + /// + CustomKeyInformation = 0x07, + + /// + /// The approximate time this key was last used, in FILETIME format. + /// + KeyApproximateLastLogonTimeStamp = 0x08, + + /// + /// The approximate time this key was created, in FILETIME format. + /// + KeyCreationTime = 0x09 + } +} diff --git a/SnaffCore/dsinternals.common/Data/Hello/KeyCredentialVersion.cs b/SnaffCore/dsinternals.common/Data/Hello/KeyCredentialVersion.cs new file mode 100644 index 00000000..27e2c13a --- /dev/null +++ b/SnaffCore/dsinternals.common/Data/Hello/KeyCredentialVersion.cs @@ -0,0 +1,13 @@ +namespace DSInternals.Common.Data +{ + /// + /// Key Credential Link Blob Structure Version + /// + /// https://msdn.microsoft.com/en-us/library/mt220501.aspx + public enum KeyCredentialVersion : uint + { + Version0 = 0, + Version1 = 0x00000100, + Version2 = 0x00000200, + } +} \ No newline at end of file diff --git a/SnaffCore/dsinternals.common/Data/Hello/KeyFlags.cs b/SnaffCore/dsinternals.common/Data/Hello/KeyFlags.cs new file mode 100644 index 00000000..ff755665 --- /dev/null +++ b/SnaffCore/dsinternals.common/Data/Hello/KeyFlags.cs @@ -0,0 +1,27 @@ +using System; + +namespace DSInternals.Common.Data +{ + /// + /// Custom Key Flags + /// + /// https://msdn.microsoft.com/en-us/library/mt220496.aspx + [Flags] + public enum KeyFlags : byte + { + /// + /// No flags specified. + /// + None = 0, + + /// + /// Reserved for future use. (CUSTOMKEYINFO_FLAGS_ATTESTATION) + /// + Attestation = 0x01, + + /// + /// During creation of this key, the requesting client authenticated using only a single credential. (CUSTOMKEYINFO_FLAGS_MFA_NOT_USED) + /// + MFANotUsed = 0x02, + } +} diff --git a/SnaffCore/dsinternals.common/Data/Hello/KeySource.cs b/SnaffCore/dsinternals.common/Data/Hello/KeySource.cs new file mode 100644 index 00000000..a9c2f925 --- /dev/null +++ b/SnaffCore/dsinternals.common/Data/Hello/KeySource.cs @@ -0,0 +1,19 @@ +namespace DSInternals.Common.Data +{ + /// + /// Key Source + /// + /// https://msdn.microsoft.com/en-us/library/mt220501.aspx + public enum KeySource : byte + { + /// + /// On Premises Key Trust + /// + AD = 0x00, + + /// + /// Hybrid Azure AD Key Trust + /// + AzureAD = 0x01 + } +} diff --git a/SnaffCore/dsinternals.common/Data/Hello/KeyStrength.cs b/SnaffCore/dsinternals.common/Data/Hello/KeyStrength.cs new file mode 100644 index 00000000..0b3ff103 --- /dev/null +++ b/SnaffCore/dsinternals.common/Data/Hello/KeyStrength.cs @@ -0,0 +1,24 @@ +namespace DSInternals.Common.Data +{ + /// + /// Specifies the strength of the NGC key. + /// + /// https://msdn.microsoft.com/en-us/library/mt220496.aspx + public enum KeyStrength : byte + { + /// + /// Key strength is unknown. + /// + Unknown = 0x00, + + /// + /// Key strength is weak. + /// + Weak = 0x01, + + /// + /// Key strength is normal. + /// + Normal = 0x02 + } +} \ No newline at end of file diff --git a/SnaffCore/dsinternals.common/Data/Hello/KeyUsage.cs b/SnaffCore/dsinternals.common/Data/Hello/KeyUsage.cs new file mode 100644 index 00000000..28b07dd7 --- /dev/null +++ b/SnaffCore/dsinternals.common/Data/Hello/KeyUsage.cs @@ -0,0 +1,47 @@ +namespace DSInternals.Common.Data +{ + /// + /// Key Usage + /// + /// https://msdn.microsoft.com/en-us/library/mt220501.aspx + public enum KeyUsage : byte + { + // Admin key (pin-reset key) + AdminKey = 0, + + /// + /// NGC key attached to a user object (KEY_USAGE_NGC) + /// + NGC = 0x01, + + /// + /// Transport key attached to a device object + /// + STK = 0x02, + + /// + /// BitLocker recovery key + /// + BitlockerRecovery = 0x03, + + /// + /// Unrecognized key usage + /// + Other = 0x04, + + /// + /// Fast IDentity Online Key (KEY_USAGE_FIDO) + /// + FIDO = 0x07, + + /// + /// File Encryption Key (KEY_USAGE_FEK) + /// + FEK = 0x08, + + /// + /// DPAPI Key + /// + DPAPI // TODO: The DPAPI enum needs to be mapped to a proper integer value. + } +} diff --git a/SnaffCore/dsinternals.common/Data/Hello/VolumeType.cs b/SnaffCore/dsinternals.common/Data/Hello/VolumeType.cs new file mode 100644 index 00000000..57e6a7df --- /dev/null +++ b/SnaffCore/dsinternals.common/Data/Hello/VolumeType.cs @@ -0,0 +1,29 @@ +namespace DSInternals.Common.Data +{ + /// + /// Specifies the volume type. + /// + /// https://msdn.microsoft.com/en-us/library/mt220496.aspx + public enum VolumeType : byte + { + /// + /// Volume not specified. + /// + None = 0x00, + + /// + /// Operating system volume (OSV). + /// + OperatingSystem = 0x01, + + /// + /// Fixed data volume (FDV). + /// + Fixed = 0x02, + + /// + /// Removable data volume (RDV). + /// + Removable = 0x03 + } +} diff --git a/SnaffCore/dsinternals.common/Extensions/ByteArrayExtensions.cs b/SnaffCore/dsinternals.common/Extensions/ByteArrayExtensions.cs new file mode 100644 index 00000000..ea5074a2 --- /dev/null +++ b/SnaffCore/dsinternals.common/Extensions/ByteArrayExtensions.cs @@ -0,0 +1,236 @@ +namespace DSInternals.Common +{ + using System; + using System.IO; + using System.Security; + using System.Security.Principal; + using System.Text; + using DSInternals.Common.Properties; + + public static class ByteArrayExtensions + { + private const string HexDigitsUpper = "0123456789ABCDEF"; + private const string HexDigitsLower = "0123456789abcdef"; + + public static void ZeroFill(this byte[] array) + { + Array.Clear(array, 0, array.Length); + } + + public static byte[] HexToBinary(this string hex, int startIndex, int length) + { + // Input validation + Validator.AssertNotNull(hex, nameof(hex)); + + if (length % 2 != 0) + { + // Each byte in a HEX string must be encoded using 2 characters. + var exception = new ArgumentException(Resources.NotHexStringMessage, nameof(hex)); + exception.Data.Add("Value", hex); + throw exception; + } + + if(startIndex < 0 || startIndex >= hex.Length ) + { + throw new ArgumentOutOfRangeException(nameof(startIndex)); + } + + if (length < 0 || startIndex + length > hex.Length) + { + throw new ArgumentOutOfRangeException(nameof(length)); + } + + // Prepare the result + byte[] bytes = new byte[length / 2]; + + // Perform the conversion + for (int nibbleIndex = 0, byteIndex = 0; nibbleIndex < length; byteIndex = ++nibbleIndex / 2) + { + char nibble = hex[startIndex + nibbleIndex]; + + if ('0' <= nibble && nibble <= '9') + { + bytes[byteIndex] = (byte)((bytes[byteIndex] << 4) | (nibble - '0')); + } + else if ('a' <= nibble && nibble <= 'f') + { + bytes[byteIndex] = (byte)((bytes[byteIndex] << 4) | (nibble - 'a' + 0xA)); + } + else if ('A' <= nibble && nibble <= 'F') + { + bytes[byteIndex] = (byte)((bytes[byteIndex] << 4) | (nibble - 'A' + 0xA)); + } + else + { + // Invalid digit + var exception = new ArgumentException(Resources.NotHexStringMessage, nameof(hex)); + exception.Data.Add("Value", hex); + throw exception; + } + } + + return bytes; + } + + public static byte[] HexToBinary(this string hex) + { + // Trivial case + if (String.IsNullOrEmpty(hex)) + { + return null; + } + + return hex.HexToBinary(0, hex.Length); + } + + public static string ToHex(this byte[] bytes, bool caps = false) + { + if (bytes == null) + { + return null; + } + + string hexDigits = caps ? HexDigitsUpper : HexDigitsLower; + + StringBuilder hex = new StringBuilder(bytes.Length * 2); + foreach(byte currentByte in bytes) + { + hex.Append(hexDigits[(int)(currentByte >> 4)]); + hex.Append(hexDigits[(int)(currentByte & 0xF)]); + } + + return hex.ToString(); + } + + public static SecureString ReadSecureWString(this byte[] buffer, int startIndex) + { + Validator.AssertNotNull(buffer, nameof(buffer)); + // TODO: Assert startIndex > 0 + int maxLength = buffer.Length - startIndex; + + // Prepare an empty SecureString that will eventually be returned + var result = new SecureString(); + + for (int i = startIndex; i < buffer.Length; i += UnicodeEncoding.CharSize) + { + // Convert the next 2 bytes from the byte array into a unicode character + char c = BitConverter.ToChar(buffer, i); + + if (c == Char.MinValue) + { + // End of string has been reached + return result; + } + + result.AppendChar(c); + } + + // If we reached this point, the \0 char has not been found, so throw an exception. + // TODO: Add a reasonable exception message + throw new ArgumentException(); + } + + public static void SwapBytes(this byte[] bytes, int index1, int index2) + { + byte temp = bytes[index1]; + bytes[index1] = bytes[index2]; + bytes[index2] = temp; + } + + /// + /// Encodes an integer into a 4-byte array, in big endian. + /// + /// The integer to encode. + /// Array of bytes, in big endian order. + public static byte[] GetBigEndianBytes(this uint number) + { + byte[] bytes = BitConverter.GetBytes(number); + if (BitConverter.IsLittleEndian) + { + Array.Reverse(bytes); + } + return bytes; + } + + public static uint ToUInt32BigEndian(this byte[] bytes, int startIndex = 0) + { + if(BitConverter.IsLittleEndian) + { + Array.Reverse(bytes); + } + + return BitConverter.ToUInt32(bytes, startIndex); + } + + public static ushort ToUInt16BigEndian(this byte[] bytes, int startIndex = 0) + { + if (BitConverter.IsLittleEndian) + { + Array.Reverse(bytes); + } + + return BitConverter.ToUInt16(bytes, startIndex); + } + + public static Guid ToGuidBigEndian(this byte[] bytes) + { + if (BitConverter.IsLittleEndian) + { + bytes.SwapBytes(0, 3); + bytes.SwapBytes(1, 2); + bytes.SwapBytes(4, 5); + bytes.SwapBytes(6, 7); + } + + return new Guid(bytes); + } + + public static SecurityIdentifier ToSecurityIdentifier(this byte[] binarySid, bool bigEndianRid = false) + { + if(binarySid == null) + { + return null; + } + byte[] output = binarySid; + if (bigEndianRid) + { + // Clone the binary SID so we do not perform byte spapping on the original value. + byte[] binarySidCopy = (byte[])binarySid.Clone(); + int lastByteIndex = binarySidCopy.Length -1; + // Convert RID from big endian to little endian (Reverse the order of the last 4 bytes) + binarySidCopy.SwapBytes(lastByteIndex - 3, lastByteIndex); + binarySidCopy.SwapBytes(lastByteIndex - 2, lastByteIndex - 1); + output = binarySidCopy; + } + return new SecurityIdentifier(output, 0); + } + + public static byte[] Cut(this byte[] blob, int offset) + { + Validator.AssertNotNull(blob, "blob"); + return blob.Cut(offset, blob.Length - offset); + } + + public static byte[] Cut(this byte[] blob, int offset, int count) + { + Validator.AssertNotNull(blob, "blob"); + Validator.AssertMinLength(blob, offset + count, "blob"); + // TODO: Check that offset and count are positive using Validator + byte[] result = new byte[count]; + Buffer.BlockCopy((Array)blob, offset, (Array)result, 0, count); + return result; + } + + public static byte[] ReadToEnd(this MemoryStream stream) + { + long remainingBytes = stream.Length - stream.Position; + if(remainingBytes > int.MaxValue) + { + throw new ArgumentOutOfRangeException("stream"); + } + byte[] buffer = new byte[remainingBytes]; + stream.Read(buffer, 0, (int)remainingBytes); + return buffer; + } + } +} diff --git a/SnaffCore/dsinternals.common/Extensions/RSAExtensions.cs b/SnaffCore/dsinternals.common/Extensions/RSAExtensions.cs new file mode 100644 index 00000000..e9114112 --- /dev/null +++ b/SnaffCore/dsinternals.common/Extensions/RSAExtensions.cs @@ -0,0 +1,138 @@ +using System; +using System.Linq; +using System.Numerics; +using System.Security.Cryptography; +using System.Security.Cryptography.X509Certificates; + +namespace DSInternals.Common +{ + public static class RSAExtensions + { + private const int BCryptKeyBlobHeaderSize = 6 * sizeof(uint); + private const uint BCryptRSAPublicKeyMagic = 0x31415352; // "RSA1" in ASCII + private const int TPM20KeyBlobHeaderSize = 4 * sizeof(int) + 9 * sizeof(uint); + private const uint TPM20PublicKeyMagic = 0x4d504350; // "MPCP" in ASCII + private const byte DERSequenceTag = 0x30; + private const int DERPublicKeyMinSize = 260; // At least 2K RSA modulus + 3B public exponent + 1B sequence tag + + /// + /// OID 1.2.840.113549.1.1.1 - Identifier for RSA encryption for use with Public Key Cryptosystem One defined by RSA Inc. + /// + private static readonly Oid RsaOid = Oid.FromFriendlyName("RSA", OidGroup.PublicKeyAlgorithm); + + /// + /// ASN.1 Tag NULL + /// + private static readonly AsnEncodedData Asn1Null = new AsnEncodedData(new byte[] { 5, 0 }); + + /// + /// BCRYPT_PUBLIC_KEY_BLOB Format + /// + private static readonly CngKeyBlobFormat BCryptRSAPublicKeyFormat = new CngKeyBlobFormat("RSAPUBLICBLOB"); + + + /// + /// Converts a RSA public key to BCRYPT_RSAKEY_BLOB. + /// + public static byte[] ExportRSAPublicKeyBCrypt(this X509Certificate2 certificate) + { + Validator.AssertNotNull(certificate, nameof(certificate)); + + using (var rsa = (RSACng)certificate.GetRSAPublicKey()) + { + using(var key = rsa.Key) + { + return key.Export(BCryptRSAPublicKeyFormat); + } + } + } + + /// + /// Decodes a public key from a BCRYPT_RSAKEY_BLOB structure. + /// + public static RSAParameters ImportRSAPublicKeyBCrypt(this byte[] blob) + { + Validator.AssertNotNull(blob, nameof(blob)); + + using (var key = CngKey.Import(blob, BCryptRSAPublicKeyFormat)) + { + using (var rsa = new RSACng(key)) + { + return rsa.ExportParameters(false); + } + } + } + + /// + /// Exports a RSA public key to the DER format. + /// + public static byte[] ExportRSAPublicKeyDER(this X509Certificate2 certificate) + { + Validator.AssertNotNull(certificate, nameof(certificate)); + + return certificate.PublicKey.EncodedKeyValue.RawData; + } + + /// + /// Decodes a DER RSA public key. + /// + public static RSAParameters ImportRSAPublicKeyDER(this byte[] blob) + { + Validator.AssertNotNull(blob, nameof(blob)); + + var asn1Key = new AsnEncodedData(blob); + var publicKey = new PublicKey(RsaOid, Asn1Null, asn1Key); + using (var rsaKey = (RSACryptoServiceProvider)publicKey.Key) + { + return rsaKey.ExportParameters(false); + } + } + + /// + /// Checks whether the input blob is in the BCRYPT_RSAKEY_BLOB format. + /// + public static bool IsBCryptRSAPublicKeyBlob(this byte[] blob) + { + if (blob == null || blob.Length < BCryptKeyBlobHeaderSize) + { + return false; + } + + // Check if the byte sequence starts with the magic + return BitConverter.ToUInt32(blob, 0) == BCryptRSAPublicKeyMagic; + } + + /// + /// Checks whether the input blob is in the PCP_KEY_BLOB_WIN8 format. + /// + public static bool IsTPM20PublicKeyBlob(this byte[] blob) + { + if (blob == null || blob.Length < TPM20KeyBlobHeaderSize) + { + return false; + } + + // Check if the byte sequence starts with the magic + return BitConverter.ToUInt32(blob, 0) == TPM20PublicKeyMagic; + } + + /// + /// Checks whether the input blob is a DER-encoded public key. + /// + public static bool IsDERPublicKeyBlob(this byte[] blob) + { + if (blob == null || blob.Length < DERPublicKeyMinSize) + { + return false; + } + + // Check if the byte sequence starts with a DER sequence tag. This is a very vague test. + return blob[0] == DERSequenceTag; + } + + public static bool IsWeakKey(this RSAParameters publicKey) + { + return false; + } + } +} diff --git a/SnaffCore/dsinternals.common/Properties/Resources.Designer.cs b/SnaffCore/dsinternals.common/Properties/Resources.Designer.cs new file mode 100644 index 00000000..91978e78 --- /dev/null +++ b/SnaffCore/dsinternals.common/Properties/Resources.Designer.cs @@ -0,0 +1,225 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace DSInternals.Common.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + public class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DSInternals.Common.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to Directory schema does not contain attribute '{0}'.. + /// + public static string AttributeNotFoundMessageFormat { + get { + return ResourceManager.GetString("AttributeNotFoundMessageFormat", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Error parsing distinguished name.. + /// + public static string DNParsingErrorMessage { + get { + return ResourceManager.GetString("DNParsingErrorMessage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The input is longer than the maximum length.. + /// + public static string InputLongerThanMaxMessage { + get { + return ResourceManager.GetString("InputLongerThanMaxMessage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The input is shorter than the minimum length.. + /// + public static string InputShorterThanMinMessage { + get { + return ResourceManager.GetString("InputShorterThanMinMessage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to CRC check failed.. + /// + public static string InvalidCRCMessage { + get { + return ResourceManager.GetString("InvalidCRCMessage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Parameter is not in the DN-Binary format.. + /// + public static string NotDNWithBinaryMessage { + get { + return ResourceManager.GetString("NotDNWithBinaryMessage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Parameter is not a hexadecimal string.. + /// + public static string NotHexStringMessage { + get { + return ResourceManager.GetString("NotHexStringMessage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Object is not an account.. + /// + public static string ObjectNotAccountMessage { + get { + return ResourceManager.GetString("ObjectNotAccountMessage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Could not find the requested object.. + /// + public static string ObjectNotFoundMessage { + get { + return ResourceManager.GetString("ObjectNotFoundMessage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Object is not a security principal.. + /// + public static string ObjectNotSecurityPrincipalMessage { + get { + return ResourceManager.GetString("ObjectNotSecurityPrincipalMessage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Object with identity '{0}' has not been found.. + /// + public static string ObjectWithIdentityNotFoundMessageFormat { + get { + return ResourceManager.GetString("ObjectWithIdentityNotFoundMessageFormat", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0} (Object identity: '{1}'). + /// + public static string OperationExceptionMessageFormat { + get { + return ResourceManager.GetString("OperationExceptionMessageFormat", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Path not found.. + /// + public static string PathNotFoundMessage { + get { + return ResourceManager.GetString("PathNotFoundMessage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The length of the input is unexpected.. + /// + public static string UnexpectedLengthMessage { + get { + return ResourceManager.GetString("UnexpectedLengthMessage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Unexpected length of the supplemental credentials structure.. + /// + public static string UnexpectedSupplementalCredsLengthMessage { + get { + return ResourceManager.GetString("UnexpectedSupplementalCredsLengthMessage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Supplemental credentials do not have a valid signature.. + /// + public static string UnexpectedSupplementalCredsSignatureMessage { + get { + return ResourceManager.GetString("UnexpectedSupplementalCredsSignatureMessage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The input contains an unexpected value '{0}', while the expected value is '{1}'.. + /// + public static string UnexpectedValueMessage { + get { + return ResourceManager.GetString("UnexpectedValueMessage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Unsupported secret encryption algorithm.. + /// + public static string UnsupportedSecretEncryptionType { + get { + return ResourceManager.GetString("UnsupportedSecretEncryptionType", resourceCulture); + } + } + } +} diff --git a/SnaffCore/dsinternals.common/Properties/Resources.resx b/SnaffCore/dsinternals.common/Properties/Resources.resx new file mode 100644 index 00000000..eaaf1663 --- /dev/null +++ b/SnaffCore/dsinternals.common/Properties/Resources.resx @@ -0,0 +1,174 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Directory schema does not contain attribute '{0}'. + + + Error parsing distinguished name. + + + The input is longer than the maximum length. + + + The input is shorter than the minimum length. + + + CRC check failed. + + + Parameter is not in the DN-Binary format. + + + Parameter is not a hexadecimal string. + + + Object is not an account. + + + Could not find the requested object. + + + Object is not a security principal. + + + Object with identity '{0}' has not been found. + + + {0} (Object identity: '{1}') + + + Path not found. + + + The length of the input is unexpected. + + + Unexpected length of the supplemental credentials structure. + + + Supplemental credentials do not have a valid signature. + + + The input contains an unexpected value '{0}', while the expected value is '{1}'. + + + Unsupported secret encryption algorithm. + + \ No newline at end of file diff --git a/SnaffCore/dsinternals.common/Validator.cs b/SnaffCore/dsinternals.common/Validator.cs new file mode 100644 index 00000000..d41aff48 --- /dev/null +++ b/SnaffCore/dsinternals.common/Validator.cs @@ -0,0 +1,117 @@ +using System; +using System.IO; +using System.Security; +using DSInternals.Common.Properties; + +namespace DSInternals.Common +{ + public static class Validator + { + public static void AssertEquals(string expectedValue, string actualValue, string paramName) + { + if(!String.Equals(expectedValue, actualValue, StringComparison.InvariantCulture)) + { + string message = String.Format(Resources.UnexpectedValueMessage, actualValue, expectedValue); + throw new ArgumentException(message, paramName); + } + } + + public static void AssertEquals(char expectedValue, char actualValue, string paramName) + { + if (expectedValue.CompareTo(actualValue) != 0) + { + string message = String.Format(Resources.UnexpectedValueMessage, actualValue, expectedValue); + throw new ArgumentException(message, paramName); + } + } + + public static void AssertNotNull(object value, string paramName) + { + if(value == null) + { + throw new ArgumentNullException(paramName); + } + } + + public static void AssertNotNullOrEmpty(string value, string paramName) + { + if (String.IsNullOrEmpty(value)) + { + throw new ArgumentNullException(paramName); + } + } + + public static void AssertNotNullOrWhiteSpace(string value, string paramName) + { + if(string.IsNullOrWhiteSpace(value)) + { + throw new ArgumentNullException(paramName); + } + } + + public static void AssertLength(string value, int length, string paramName) + { + AssertNotNull(value, paramName); + if(value.Length != length) + { + throw new ArgumentOutOfRangeException(paramName, value.Length, Resources.UnexpectedLengthMessage); + } + } + + public static void AssertMaxLength(SecureString password, int maxLength, string paramName) + { + AssertNotNull(password, paramName); + if (password.Length > maxLength) + { + throw new ArgumentOutOfRangeException(paramName, password.Length, Resources.InputLongerThanMaxMessage); + } + } + + public static void AssertMaxLength(string input, int maxLength, string paramName) + { + AssertNotNull(input, paramName); + if (input.Length > maxLength) + { + throw new ArgumentOutOfRangeException(paramName, input.Length, Resources.InputLongerThanMaxMessage); + } + } + + public static void AssertMinLength(byte[] data, int minLength, string paramName) + { + AssertNotNull(data, paramName); + if (data.Length < minLength) + { + var exception = new ArgumentOutOfRangeException(paramName, data.Length, Resources.InputShorterThanMinMessage); + // DEBUG: exception.Data.Add("BinaryBlob", data.ToHex()); + throw exception; + } + } + + public static void AssertLength(byte[] value, long length, string paramName) + { + AssertNotNull(value, paramName); + if (value.Length != length) + { + throw new ArgumentOutOfRangeException(paramName, value.Length, Resources.UnexpectedLengthMessage); + } + } + + public static void AssertFileExists(string filePath) + { + bool exists = File.Exists(filePath); + if(!exists) + { + throw new FileNotFoundException(Resources.PathNotFoundMessage, filePath); + } + } + + public static void AssertDirectoryExists(string directoryPath) + { + bool exists = Directory.Exists(directoryPath); + if (!exists) + { + throw new DirectoryNotFoundException(Resources.PathNotFoundMessage); + } + } + } +} diff --git a/Snaffler/Config.cs b/Snaffler/Config.cs index e9aedb21..93e11442 100644 --- a/Snaffler/Config.cs +++ b/Snaffler/Config.cs @@ -78,6 +78,9 @@ private static Options ParseImpl(string[] args) SwitchArgument stdOutArg = new SwitchArgument('s', "stdout", "Enables outputting results to stdout as soon as they're found. You probably want this if you're not using -o.", false); + SwitchArgument adwsEnum = new SwitchArgument('w', "adws", + "Using a opsec method to query domain computer.", + false); ValueArgument interestLevel = new ValueArgument('b', "interest", "Interest level to report (0-3)"); ValueArgument snaffleArg = new ValueArgument('m', "snaffle", "Enables and assigns an output dir for Snaffler to automatically snaffle a copy of any found files."); @@ -114,6 +117,9 @@ private static Options ParseImpl(string[] args) parser.Arguments.Add(outFileArg); parser.Arguments.Add(helpArg); parser.Arguments.Add(stdOutArg); + parser.Arguments.Add(adwsEnum); + + parser.Arguments.Add(snaffleArg); parser.Arguments.Add(snaffleSizeArg); parser.Arguments.Add(dirTargetArg); @@ -137,7 +143,7 @@ private static Options ParseImpl(string[] args) if ((args.Contains("--help") || args.Contains("/?") || args.Contains("help") || args.Contains("-h") || args.Length == 0)) { parser.ShowUsage(); - return null; + return null; } TomlSettings settings = TomlSettings.Create(cfg => cfg @@ -235,7 +241,7 @@ private static Options ParseImpl(string[] args) throw new Exception("Failed to get a valid list of excluded computers from the excluded computers list."); } } - + if (compTargetArg.Parsed) { List compTargets = new List(); @@ -285,6 +291,7 @@ private static Options ParseImpl(string[] args) // if enabled, display findings to the console parsedConfig.LogToConsole = stdOutArg.Parsed; + parsedConfig.ADWS = adwsEnum.Parsed; Mq.Degub("Enabled logging to stdout."); // args that tell us about targeting @@ -336,7 +343,7 @@ private static Options ParseImpl(string[] args) } parsedConfig.PathTargets.Add(pathTarget); } - + //Console.WriteLine(parsedConfig.PathTargets[0]); foreach (string pathTarget in parsedConfig.PathTargets) { @@ -413,7 +420,7 @@ private static Options ParseImpl(string[] args) if (parsedConfig.ClassifierRules.Count <= 0) { if (String.IsNullOrWhiteSpace(parsedConfig.RuleDir)) - { + { // get all the embedded toml file resources string[] resourceNames = Assembly.GetExecutingAssembly().GetManifestResourceNames(); StringBuilder sb = new StringBuilder(); diff --git a/Snaffler/Properties/Resources.Designer.cs b/Snaffler/Properties/Resources.Designer.cs index 01383f00..1d198dbf 100644 --- a/Snaffler/Properties/Resources.Designer.cs +++ b/Snaffler/Properties/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace Snaffler.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "18.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] public class Resources { diff --git a/Snaffler/Snaffler.csproj b/Snaffler/Snaffler.csproj index f84fdba9..cf22b851 100644 --- a/Snaffler/Snaffler.csproj +++ b/Snaffler/Snaffler.csproj @@ -14,6 +14,22 @@ + false + C:\Users\leets\Documents\hackingDev\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 2 + 1.0.0.%2a + false + true + true AnyCPU @@ -58,6 +74,18 @@ 7.3 prompt + + D49BB175432D1CDBEB1C3EB73FD2DB70985B8BB1 + + + Snaffler_TemporaryKey.pfx + + + true + + + true + @@ -86,6 +114,7 @@ + @@ -110,6 +139,17 @@ 4.7.15 - + + + False + Microsoft .NET Framework 4.8 %28x86 and x64%29 + true + + + False + .NET Framework 3.5 SP1 + false + + \ No newline at end of file