Imported Upstream version 5.8.0.22

Former-commit-id: df344e34b07851d296efb3e6604c8db42b6f7aa3
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-10-19 20:04:20 +00:00
parent 5f4a27cc8a
commit 7d05485754
5020 changed files with 114082 additions and 186061 deletions

View File

@@ -2,6 +2,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.DirectoryServices.Tests", "tests\System.DirectoryServices.Tests.csproj", "{DDE3838B-0EEA-4D9A-A120-9D72CB33F250}"
ProjectSection(ProjectDependencies) = postProject
{EC9B0FBC-C3A2-44E6-BFC6-51E565061C28} = {EC9B0FBC-C3A2-44E6-BFC6-51E565061C28}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.DirectoryServices", "src\System.DirectoryServices.csproj", "{EC9B0FBC-C3A2-44E6-BFC6-51E565061C28}"
ProjectSection(ProjectDependencies) = postProject
{CBCDA53B-4C01-4267-B08C-413205FE4D8D} = {CBCDA53B-4C01-4267-B08C-413205FE4D8D}
@@ -9,6 +14,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.DirectoryServices",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.DirectoryServices", "ref\System.DirectoryServices.csproj", "{CBCDA53B-4C01-4267-B08C-413205FE4D8D}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{1A2F9F4A-A032-433E-B914-ADD5992BB178}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{E107E9C1-E893-4E87-987E-04EF0DCEAEFD}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{2E666815-2EDB-464B-9DF6-380BF4789AD4}"
@@ -19,6 +26,10 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{DDE3838B-0EEA-4D9A-A120-9D72CB33F250}.Debug|Any CPU.ActiveCfg = netstandard-Windows_NT-Debug|Any CPU
{DDE3838B-0EEA-4D9A-A120-9D72CB33F250}.Debug|Any CPU.Build.0 = netstandard-Windows_NT-Debug|Any CPU
{DDE3838B-0EEA-4D9A-A120-9D72CB33F250}.Release|Any CPU.ActiveCfg = netstandard-Windows_NT-Release|Any CPU
{DDE3838B-0EEA-4D9A-A120-9D72CB33F250}.Release|Any CPU.Build.0 = netstandard-Windows_NT-Release|Any CPU
{EC9B0FBC-C3A2-44E6-BFC6-51E565061C28}.Debug|Any CPU.ActiveCfg = netstandard-Windows_NT-Debug|Any CPU
{EC9B0FBC-C3A2-44E6-BFC6-51E565061C28}.Debug|Any CPU.Build.0 = netstandard-Windows_NT-Debug|Any CPU
{EC9B0FBC-C3A2-44E6-BFC6-51E565061C28}.Release|Any CPU.ActiveCfg = netstandard-Windows_NT-Release|Any CPU
@@ -32,6 +43,7 @@ Global
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{DDE3838B-0EEA-4D9A-A120-9D72CB33F250} = {1A2F9F4A-A032-433E-B914-ADD5992BB178}
{EC9B0FBC-C3A2-44E6-BFC6-51E565061C28} = {E107E9C1-E893-4E87-987E-04EF0DCEAEFD}
{CBCDA53B-4C01-4267-B08C-413205FE4D8D} = {2E666815-2EDB-464B-9DF6-380BF4789AD4}
EndGlobalSection

View File

@@ -2,9 +2,10 @@
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\dir.props" />
<PropertyGroup>
<!-- this assembly is inbox in desktop, do not version it unless you
plan on shipping a new desktop version out of band. Instead add API
to a different assembly. -->
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyKey>MSFT</AssemblyKey>
<!-- disable package until https://github.com/dotnet/corefx/issues/18090 is addressed -->
<ShouldCreatePackage>false</ShouldCreatePackage>
</PropertyGroup>
</Project>

View File

@@ -17,4 +17,3 @@ namespace System.DirectoryServices.Interop
ADS_USE_SEALING = 0x80
}
}

View File

@@ -16,4 +16,3 @@ namespace System.DirectoryServices.Interop
ADS_OPTION_PASSWORD_METHOD = 7
}
}

View File

@@ -2,23 +2,13 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
/*
*/
namespace System.DirectoryServices.Interop
{
using System;
using System.Runtime.InteropServices;
using System.Diagnostics;
internal enum AdsPropertyOperation
{
Clear = 1,
Update = 2,
Append = 3,
Delete = 4
}
}

View File

@@ -2,11 +2,10 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Runtime.InteropServices;
namespace System.DirectoryServices.Interop
{
using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential)]
internal unsafe struct AdsSearchColumn
{
@@ -17,4 +16,3 @@ namespace System.DirectoryServices.Interop
public IntPtr hReserved;
}
}

View File

@@ -2,11 +2,10 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Runtime.InteropServices;
namespace System.DirectoryServices.Interop
{
using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential)]
internal struct AdsSearchPreferenceInfo
{
@@ -17,4 +16,3 @@ namespace System.DirectoryServices.Interop
internal int pad2;
}
}

View File

@@ -27,4 +27,3 @@ namespace System.DirectoryServices.Interop
EXTENDED_DN = 18
}
}

View File

@@ -2,11 +2,10 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Runtime.InteropServices;
namespace System.DirectoryServices.Interop
{
using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential)]
internal struct AdsSortKey
{
@@ -15,4 +14,3 @@ namespace System.DirectoryServices.Interop
public int fReverseOrder;
}
}

View File

@@ -11,4 +11,3 @@ namespace System.DirectoryServices.Interop
ADS_STATUS_INVALID_SEARCHPREFVALUE = 2
}
}

View File

@@ -37,4 +37,3 @@ namespace System.DirectoryServices.Interop
ADSTYPE_DN_WITH_STRING = 28
}
}

View File

@@ -2,11 +2,10 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Runtime.InteropServices;
namespace System.DirectoryServices.Interop
{
using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential)]
internal struct Ads_Pointer
{
@@ -44,4 +43,3 @@ namespace System.DirectoryServices.Interop
public Ads_Generic generic;
}
}

View File

@@ -2,14 +2,12 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Text;
using System.Runtime.InteropServices;
using System.Globalization;
namespace System.DirectoryServices.Interop
{
using System;
using System.Text;
using System.Runtime.InteropServices;
using System.Globalization;
using System.Security.Permissions;
[StructLayout(LayoutKind.Sequential)]
internal struct SystemTime
{
@@ -38,7 +36,9 @@ namespace System.DirectoryServices.Interop
public IntPtr pszDNString; // Distinguished Name
}
// helper class for dealing with struct AdsValue.
/// <summary>
/// Helper class for dealing with struct AdsValue.
/// </summary>
internal class AdsValueHelper
{
public AdsValue adsvalue;
@@ -62,10 +62,7 @@ namespace System.DirectoryServices.Interop
public long LowInt64
{
get
{
return (long)((uint)adsvalue.generic.a + (((long)adsvalue.generic.b) << 32));
}
get => (uint)adsvalue.generic.a + (((long)adsvalue.generic.b) << 32);
set
{
adsvalue.generic.a = (int)(value & 0xFFFFFFFF);
@@ -76,73 +73,80 @@ namespace System.DirectoryServices.Interop
~AdsValueHelper()
{
if (_pinnedHandle.IsAllocated)
{
_pinnedHandle.Free();
}
}
private AdsType GetAdsTypeForManagedType(Type type)
{
//Consider this code is only excercised by DirectorySearcher
//it just translates the types needed by such a component, if more managed
//types are to be used in the future, this function needs to be expanded.
// Consider this code is only excercised by DirectorySearcher
// it just translates the types needed by such a component, if more managed
// types are to be used in the future, this function needs to be expanded.
if (type == typeof(int))
{
return AdsType.ADSTYPE_INTEGER;
}
if (type == typeof(long))
{
return AdsType.ADSTYPE_LARGE_INTEGER;
}
if (type == typeof(bool))
{
return AdsType.ADSTYPE_BOOLEAN;
}
return AdsType.ADSTYPE_UNKNOWN;
}
public AdsValue GetStruct()
{
return adsvalue;
}
public AdsValue GetStruct() => adsvalue;
private static ushort LowOfInt(int i)
{
return unchecked((ushort)(i & 0xFFFF));
}
private static ushort LowOfInt(int i) => unchecked((ushort)(i & 0xFFFF));
private static ushort HighOfInt(int i)
{
return unchecked((ushort)((i >> 16) & 0xFFFF));
}
private static ushort HighOfInt(int i) => unchecked((ushort)((i >> 16) & 0xFFFF));
public object GetValue()
{
switch ((AdsType)adsvalue.dwType)
{
// Common for DNS and LDAP
// Common for DNS and LDAP.
case AdsType.ADSTYPE_UTC_TIME:
{
SystemTime st = new SystemTime();
st.wYear = LowOfInt(adsvalue.generic.a);
st.wMonth = HighOfInt(adsvalue.generic.a);
st.wDayOfWeek = LowOfInt(adsvalue.generic.b);
st.wDay = HighOfInt(adsvalue.generic.b);
st.wHour = LowOfInt(adsvalue.generic.c);
st.wMinute = HighOfInt(adsvalue.generic.c);
st.wSecond = LowOfInt(adsvalue.generic.d);
st.wMilliseconds = HighOfInt(adsvalue.generic.d);
var st = new SystemTime()
{
wYear = LowOfInt(adsvalue.generic.a),
wMonth = HighOfInt(adsvalue.generic.a),
wDayOfWeek = LowOfInt(adsvalue.generic.b),
wDay = HighOfInt(adsvalue.generic.b),
wHour = LowOfInt(adsvalue.generic.c),
wMinute = HighOfInt(adsvalue.generic.c),
wSecond = LowOfInt(adsvalue.generic.d),
wMilliseconds = HighOfInt(adsvalue.generic.d)
};
return new DateTime(st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, st.wMilliseconds);
}
case AdsType.ADSTYPE_DN_WITH_BINARY:
{
DnWithBinary dnb = new DnWithBinary();
var dnb = new DnWithBinary();
Marshal.PtrToStructure(adsvalue.pointer.value, dnb);
byte[] bytes = new byte[dnb.dwLength];
Marshal.Copy(dnb.lpBinaryValue, bytes, 0, dnb.dwLength);
StringBuilder strb = new StringBuilder();
StringBuilder binaryPart = new StringBuilder();
var strb = new StringBuilder();
var binaryPart = new StringBuilder();
for (int i = 0; i < bytes.Length; i++)
{
string s = bytes[i].ToString("X", CultureInfo.InvariantCulture);
if (s.Length == 1)
{
binaryPart.Append("0");
}
binaryPart.Append(s);
}
@@ -152,24 +156,24 @@ namespace System.DirectoryServices.Interop
strb.Append(binaryPart.ToString());
strb.Append(":");
strb.Append(Marshal.PtrToStringUni(dnb.pszDNString));
return strb.ToString();
}
case AdsType.ADSTYPE_DN_WITH_STRING:
{
DnWithString dns = new DnWithString();
var dns = new DnWithString();
Marshal.PtrToStructure(adsvalue.pointer.value, dns);
string strValue = Marshal.PtrToStringUni(dns.pszStringValue);
if (strValue == null)
strValue = "";
string strValue = Marshal.PtrToStringUni(dns.pszStringValue) ?? string.Empty;
StringBuilder strb = new StringBuilder();
var strb = new StringBuilder();
strb.Append("S:");
strb.Append(strValue.Length);
strb.Append(":");
strb.Append(strValue);
strb.Append(":");
strb.Append(Marshal.PtrToStringUni(dns.pszDNString));
return strb.ToString();
}
@@ -179,21 +183,21 @@ namespace System.DirectoryServices.Interop
case AdsType.ADSTYPE_PRINTABLE_STRING:
case AdsType.ADSTYPE_NUMERIC_STRING:
case AdsType.ADSTYPE_OBJECT_CLASS:
// string
// The value is a String.
return Marshal.PtrToStringUni(adsvalue.pointer.value);
case AdsType.ADSTYPE_BOOLEAN:
// bool
// The value is a bool.
return adsvalue.generic.a != 0;
case AdsType.ADSTYPE_INTEGER:
// int
// The value is an int.
return adsvalue.generic.a;
case AdsType.ADSTYPE_NT_SECURITY_DESCRIPTOR:
case AdsType.ADSTYPE_OCTET_STRING:
case AdsType.ADSTYPE_PROV_SPECIFIC:
// byte[]
// The value is a byte[].
int len = adsvalue.octetString.length;
byte[] value = new byte[len];
Marshal.Copy(adsvalue.octetString.value, value, 0, len);
@@ -205,7 +209,7 @@ namespace System.DirectoryServices.Interop
case AdsType.ADSTYPE_LARGE_INTEGER:
return LowInt64;
// not used in LDAP
// Not used in LDAP
case AdsType.ADSTYPE_CASEIGNORE_LIST:
case AdsType.ADSTYPE_OCTET_LIST:
case AdsType.ADSTYPE_PATH:
@@ -220,36 +224,40 @@ namespace System.DirectoryServices.Interop
case AdsType.ADSTYPE_TYPEDNAME:
case AdsType.ADSTYPE_REPLICAPOINTER:
case AdsType.ADSTYPE_UNKNOWN:
return new NotImplementedException(String.Format(CultureInfo.CurrentCulture, SR.DSAdsvalueTypeNYI , "0x" + Convert.ToString(adsvalue.dwType, 16)));
return new NotImplementedException(SR.Format(SR.DSAdsvalueTypeNYI , "0x" + Convert.ToString(adsvalue.dwType, 16)));
default:
return new ArgumentException(String.Format(CultureInfo.CurrentCulture, SR.DSConvertFailed , "0x" + Convert.ToString(LowInt64, 16), "0x" + Convert.ToString(adsvalue.dwType, 16)));
return new ArgumentException(SR.Format(SR.DSConvertFailed , "0x" + Convert.ToString(LowInt64, 16), "0x" + Convert.ToString(adsvalue.dwType, 16)));
}
}
public object GetVlvValue()
{
AdsVLV vlv = new AdsVLV();
var vlv = new AdsVLV();
Marshal.PtrToStructure(adsvalue.octetString.value, vlv);
byte[] bytes = null;
if (vlv.contextID != (IntPtr)0 && vlv.contextIDlength != 0)
{
bytes = new byte[vlv.contextIDlength];
Marshal.Copy(vlv.contextID, bytes, 0, vlv.contextIDlength);
}
DirectoryVirtualListView vlvResponse = new DirectoryVirtualListView();
vlvResponse.Offset = vlv.offset;
vlvResponse.ApproximateTotal = vlv.contentCount;
DirectoryVirtualListViewContext context = new DirectoryVirtualListViewContext(bytes);
vlvResponse.DirectoryVirtualListViewContext = context;
return vlvResponse;
return new DirectoryVirtualListView
{
Offset = vlv.offset,
ApproximateTotal = vlv.contentCount,
DirectoryVirtualListViewContext = new DirectoryVirtualListViewContext(bytes)
};
}
private unsafe void SetValue(object managedValue, AdsType adsType)
{
adsvalue = new AdsValue();
adsvalue.dwType = (int)adsType;
adsvalue = new AdsValue()
{
dwType = (int)adsType
};
switch (adsType)
{
case AdsType.ADSTYPE_INTEGER:
@@ -260,10 +268,7 @@ namespace System.DirectoryServices.Interop
LowInt64 = (long)managedValue;
break;
case AdsType.ADSTYPE_BOOLEAN:
if ((bool)managedValue)
LowInt64 = -1;
else
LowInt64 = 0;
LowInt64 = (bool)managedValue ? -1 : 0;
break;
case AdsType.ADSTYPE_CASE_IGNORE_STRING:
_pinnedHandle = GCHandle.Alloc(managedValue, GCHandleType.Pinned);
@@ -271,7 +276,7 @@ namespace System.DirectoryServices.Interop
break;
case AdsType.ADSTYPE_PROV_SPECIFIC:
byte[] bytes = (byte[])managedValue;
// filling in an ADS_PROV_SPECIFIC struct.
// Filling in an ADS_PROV_SPECIFIC struct.
// 1st dword (our member a) is DWORD dwLength.
// 2nd dword (our member b) is byte *lpValue.
adsvalue.octetString.length = bytes.Length;
@@ -279,9 +284,8 @@ namespace System.DirectoryServices.Interop
adsvalue.octetString.value = _pinnedHandle.AddrOfPinnedObject();
break;
default:
throw new NotImplementedException(String.Format(CultureInfo.CurrentCulture, SR.DSAdsvalueTypeNYI , "0x" + Convert.ToString((int)adsType, 16)));
throw new NotImplementedException(SR.Format(SR.DSAdsvalueTypeNYI , "0x" + Convert.ToString((int)adsType, 16)));
}
}
}
}

View File

@@ -4,14 +4,6 @@
namespace System.DirectoryServices.Interop
{
#pragma warning disable BCL0015 // CoreFXPort
using System.Runtime.InteropServices;
using System;
using System.Security.Permissions;
using System.Collections;
using System.IO;
using System.Text;
internal class NativeMethods
{
public enum AuthenticationModes
@@ -20,7 +12,6 @@ namespace System.DirectoryServices.Interop
UseEncryption = 0x2,
UseSSL = 0x2,
ReadonlyServer = 0x4,
// PromptCredentials = 0x8, // Deprecated by ADSI
NoAuthentication = 0x10,
FastBind = 0x20,
UseSigning = 0x40,
@@ -30,4 +21,3 @@ namespace System.DirectoryServices.Interop
}
}
}

View File

@@ -2,61 +2,54 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Text;
using System.Security;
using System.Runtime.InteropServices;
namespace System.DirectoryServices.Interop
{
using System;
using System.Text;
using System.Security;
using System.Security.Permissions;
using System.Runtime.InteropServices;
#pragma warning disable BCL0015 // CoreFxPort
[
SuppressUnmanagedCodeSecurityAttribute()
]
[SuppressUnmanagedCodeSecurity]
internal class SafeNativeMethods
{
[DllImport(ExternDll.Oleaut32, PreserveSig = false)]
public static extern void VariantClear(IntPtr pObject);
[DllImport(ExternDll.Oleaut32)]
public static extern void VariantInit(IntPtr pObject);
[DllImport(ExternDll.Activeds)]
public static extern bool FreeADsMem(IntPtr pVoid);
public const int FORMAT_MESSAGE_ALLOCATE_BUFFER = 0x00000100,
public const int
FORMAT_MESSAGE_IGNORE_INSERTS = 0x00000200,
FORMAT_MESSAGE_FROM_STRING = 0x00000400,
FORMAT_MESSAGE_FROM_HMODULE = 0x00000800,
FORMAT_MESSAGE_FROM_SYSTEM = 0x00001000,
FORMAT_MESSAGE_ARGUMENT_ARRAY = 0x00002000,
FORMAT_MESSAGE_MAX_WIDTH_MASK = 0x000000FF,
ERROR_MORE_DATA = 234,
ERROR_SUCCESS = 0;
[DllImport(ExternDll.Activeds, CharSet = System.Runtime.InteropServices.CharSet.Unicode)]
[DllImport(ExternDll.Activeds, CharSet = CharSet.Unicode)]
public static extern int ADsGetLastError(out int error, StringBuilder errorBuffer,
int errorBufferLength, StringBuilder nameBuffer, int nameBufferLength);
[DllImport(ExternDll.Activeds, CharSet = System.Runtime.InteropServices.CharSet.Unicode)]
[DllImport(ExternDll.Activeds, CharSet = CharSet.Unicode)]
public static extern int ADsSetLastError(int error, string errorString, string provider);
[DllImport(ExternDll.Kernel32, CharSet = System.Runtime.InteropServices.CharSet.Unicode)]
[DllImport(ExternDll.Kernel32, CharSet = CharSet.Unicode)]
public static extern int FormatMessageW(int dwFlags, int lpSource, int dwMessageId,
int dwLanguageId, StringBuilder lpBuffer, int nSize, int arguments);
public class EnumVariant
{
private static readonly object s_noMoreValues = new object();
private Object _currentValue = s_noMoreValues;
private object _currentValue = s_noMoreValues;
private IEnumVariant _enumerator;
public EnumVariant(IEnumVariant en)
{
if (en == null)
throw new ArgumentNullException("en");
_enumerator = en;
_enumerator = en ?? throw new ArgumentNullException(nameof(en));
}
/// <include file='doc\SafeNativeMethods.uex' path='docs/doc[@for="SafeNativeMethods.EnumVariant.GetNext"]/*' />
/// <devdoc>
/// Moves the enumerator to the next value In the list.
/// </devdoc>
@@ -66,19 +59,20 @@ namespace System.DirectoryServices.Interop
return _currentValue != s_noMoreValues;
}
/// <include file='doc\SafeNativeMethods.uex' path='docs/doc[@for="SafeNativeMethods.EnumVariant.GetValue"]/*' />
/// <devdoc>
/// Returns the current value of the enumerator. If GetNext() has never been called,
/// or if it has been called but it returned false, will throw an exception.
/// </devdoc>
public Object GetValue()
public object GetValue()
{
if (_currentValue == s_noMoreValues)
{
throw new InvalidOperationException(SR.DSEnumerator);
}
return _currentValue;
}
/// <include file='doc\SafeNativeMethods.uex' path='docs/doc[@for="SafeNativeMethods.EnumVariant.Reset"]/*' />
/// <devdoc>
/// Returns the enumerator to the start of the sequence.
/// </devdoc>
@@ -88,7 +82,6 @@ namespace System.DirectoryServices.Interop
_currentValue = s_noMoreValues;
}
/// <include file='doc\SafeNativeMethods.uex' path='docs/doc[@for="SafeNativeMethods.EnumVariant.Advance"]/*' />
/// <devdoc>
/// Moves the pointer to the next value In the contained IEnumVariant, and
/// stores the current value In currentValue.
@@ -100,7 +93,7 @@ namespace System.DirectoryServices.Interop
try
{
int[] numRead = new int[] { 0 };
SafeNativeMethods.VariantInit(addr);
VariantInit(addr);
_enumerator.Next(1, addr, numRead);
try
@@ -114,7 +107,7 @@ namespace System.DirectoryServices.Interop
}
finally
{
SafeNativeMethods.VariantClear(addr);
VariantClear(addr);
}
}
finally
@@ -124,30 +117,24 @@ namespace System.DirectoryServices.Interop
}
}
[ComImport(), Guid("00020404-0000-0000-C000-000000000046"), System.Runtime.InteropServices.InterfaceTypeAttribute(System.Runtime.InteropServices.ComInterfaceType.InterfaceIsIUnknown)]
[ComImport]
[Guid("00020404-0000-0000-C000-000000000046")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IEnumVariant
{
[SuppressUnmanagedCodeSecurityAttribute()]
void Next(
[In, MarshalAs(UnmanagedType.U4)]
int celt,
[In, Out]
IntPtr rgvar,
[Out, MarshalAs(UnmanagedType.LPArray)]
int[] pceltFetched);
[SuppressUnmanagedCodeSecurity]
void Next([In, MarshalAs(UnmanagedType.U4)] int celt,
[In, Out] IntPtr rgvar,
[Out, MarshalAs(UnmanagedType.LPArray)] int[] pceltFetched);
[SuppressUnmanagedCodeSecurityAttribute()]
void Skip(
[In, MarshalAs(UnmanagedType.U4)]
int celt);
[SuppressUnmanagedCodeSecurity]
void Skip([In, MarshalAs(UnmanagedType.U4)] int celt);
[SuppressUnmanagedCodeSecurityAttribute()]
[SuppressUnmanagedCodeSecurity]
void Reset();
[SuppressUnmanagedCodeSecurityAttribute()]
void Clone(
[Out, MarshalAs(UnmanagedType.LPArray)]
IEnumVariant[] ppenum);
[SuppressUnmanagedCodeSecurity]
void Clone([Out, MarshalAs(UnmanagedType.LPArray)] IEnumVariant[] ppenum);
}
}
}

View File

@@ -19,7 +19,6 @@
</ItemGroup>
<ItemGroup Condition="'$(TargetsWindows)' == 'true'">
<Compile Include="System\DirectoryServices\externdll.cs" />
<Compile Include="System\DirectoryServices\PrivilegedConfigurationManager.cs" />
<Compile Include="System\DirectoryServices\ActiveDirectorySecurity.cs" />
<Compile Include="System\DirectoryServices\AdsVLV.cs" />
<Compile Include="System\DirectoryServices\AuthenticationTypes.cs" />
@@ -47,7 +46,6 @@
<Compile Include="System\DirectoryServices\SearchResult.cs" />
<Compile Include="System\DirectoryServices\SearchResultCollection.cs" />
<Compile Include="System\DirectoryServices\SearchScope.cs" />
<Compile Include="System\DirectoryServices\SearchWaitHandler.cs" />
<Compile Include="System\DirectoryServices\SecurityMasks.cs" />
<Compile Include="System\DirectoryServices\SortDirection.cs" />
<Compile Include="System\DirectoryServices\SortOption.cs" />

View File

@@ -2,20 +2,16 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Net;
using System.Collections;
using System.ComponentModel;
using System.Runtime.InteropServices;
namespace System.DirectoryServices.ActiveDirectory
{
using System;
using System.Net;
using System.Collections;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Threading;
using System.Security.Permissions;
using System.Globalization;
public class AdamInstance : DirectoryServer
{
private string[] _becomeRoleOwnerAttrs = null;
private readonly string[] _becomeRoleOwnerAttrs = null;
private bool _disposed = false;
// for public properties
@@ -31,7 +27,7 @@ namespace System.DirectoryServices.ActiveDirectory
private IntPtr _ADAMHandle = (IntPtr)0;
private IntPtr _authIdentity = IntPtr.Zero;
private SyncUpdateCallback _userDelegate = null;
private SyncReplicaFromAllServersCallback _syncAllFunctionPointer = null;
private readonly SyncReplicaFromAllServersCallback _syncAllFunctionPointer = null;
#region constructors
internal AdamInstance(DirectoryContext context, string adamInstanceName)
@@ -132,7 +128,7 @@ namespace System.DirectoryServices.ActiveDirectory
// target must be a server
if ((!context.isServer()))
{
throw new ActiveDirectoryObjectNotFoundException(String.Format(CultureInfo.CurrentCulture, SR.AINotFound , context.Name), typeof(AdamInstance), context.Name);
throw new ActiveDirectoryObjectNotFoundException(SR.Format(SR.AINotFound , context.Name), typeof(AdamInstance), context.Name);
}
// work with copy of the context
@@ -147,7 +143,7 @@ namespace System.DirectoryServices.ActiveDirectory
// This will ensure that we are talking to ADAM instance only
if (!Utils.CheckCapability(rootDSE, Capability.ActiveDirectoryApplicationMode))
{
throw new ActiveDirectoryObjectNotFoundException(String.Format(CultureInfo.CurrentCulture, SR.AINotFound , context.Name), typeof(AdamInstance), context.Name);
throw new ActiveDirectoryObjectNotFoundException(SR.Format(SR.AINotFound , context.Name), typeof(AdamInstance), context.Name);
}
dnsHostName = (string)PropertyManager.GetPropertyValue(context, rootDSE, PropertyManager.DnsHostName);
}
@@ -157,7 +153,7 @@ namespace System.DirectoryServices.ActiveDirectory
if (errorCode == unchecked((int)0x8007203a))
{
throw new ActiveDirectoryObjectNotFoundException(String.Format(CultureInfo.CurrentCulture, SR.AINotFound , context.Name), typeof(AdamInstance), context.Name);
throw new ActiveDirectoryObjectNotFoundException(SR.Format(SR.AINotFound , context.Name), typeof(AdamInstance), context.Name);
}
else
{
@@ -664,7 +660,7 @@ namespace System.DirectoryServices.ActiveDirectory
// this adam instance
if (!Partitions.Contains(value))
{
throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, SR.ServerNotAReplica , value), "value");
throw new ArgumentException(SR.Format(SR.ServerNotAReplica , value), "value");
}
ntdsaEntry.Properties[PropertyManager.MsDSDefaultNamingContext].Value = value;
}
@@ -821,21 +817,9 @@ namespace System.DirectoryServices.ActiveDirectory
}
}
public override ReplicationConnectionCollection InboundConnections
{
get
{
return GetInboundConnectionsHelper();
}
}
public override ReplicationConnectionCollection InboundConnections => GetInboundConnectionsHelper();
public override ReplicationConnectionCollection OutboundConnections
{
get
{
return GetOutboundConnectionsHelper();
}
}
public override ReplicationConnectionCollection OutboundConnections => GetOutboundConnectionsHelper();
#endregion public properties

View File

@@ -2,12 +2,10 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Collections;
namespace System.DirectoryServices.ActiveDirectory
{
using System;
using System.Globalization;
using System.Collections;
public class AdamInstanceCollection : ReadOnlyCollectionBase
{
internal AdamInstanceCollection() { }
@@ -20,13 +18,7 @@ namespace System.DirectoryServices.ActiveDirectory
}
}
public AdamInstance this[int index]
{
get
{
return (AdamInstance)InnerList[index];
}
}
public AdamInstance this[int index] => (AdamInstance)InnerList[index];
public bool Contains(AdamInstance adamInstance)
{

View File

@@ -2,15 +2,13 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Collections.Specialized;
namespace System.DirectoryServices.ActiveDirectory
{
using System;
using System.Collections.Specialized;
using System.Security.Permissions;
internal class ADSearcher
{
private DirectorySearcher _searcher = null;
private readonly DirectorySearcher _searcher = null;
private static TimeSpan s_defaultTimeSpan = new TimeSpan(0, 120, 0);
public ADSearcher(DirectoryEntry searchRoot, string filter, string[] propertiesToLoad, SearchScope scope)
@@ -40,49 +38,21 @@ namespace System.DirectoryServices.ActiveDirectory
_searcher.ServerPageTimeLimit = s_defaultTimeSpan;
}
if (cacheResults)
{
_searcher.CacheResults = true;
}
else
{
_searcher.CacheResults = false;
}
_searcher.CacheResults = cacheResults;
}
public SearchResult FindOne()
{
return _searcher.FindOne();
}
public SearchResult FindOne() => _searcher.FindOne();
public SearchResultCollection FindAll()
{
return _searcher.FindAll();
}
public SearchResultCollection FindAll() => _searcher.FindAll();
public StringCollection PropertiesToLoad
{
get
{
return _searcher.PropertiesToLoad;
}
}
public StringCollection PropertiesToLoad => _searcher.PropertiesToLoad;
public string Filter
{
get
{
return _searcher.Filter;
}
set
{
_searcher.Filter = value;
}
get => _searcher.Filter;
set => _searcher.Filter = value;
}
public void Dispose()
{
_searcher.Dispose();
}
public void Dispose() => _searcher.Dispose();
}
}

Some files were not shown because too many files have changed in this diff Show More