Imported Upstream version 5.10.0.47

Former-commit-id: d0813289fa2d35e1f8ed77530acb4fb1df441bc0
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2018-01-24 17:04:36 +00:00
parent 88ff76fe28
commit e46a49ecf1
5927 changed files with 226314 additions and 129848 deletions

View File

@@ -18,7 +18,7 @@
<Compile Include="FxCopBaseline.AnyOS.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetsWindows)' == 'true'">
<Compile Include="System\DirectoryServices\externdll.cs" />
<Compile Include="System\DirectoryServices\ExternDll.cs" />
<Compile Include="System\DirectoryServices\ActiveDirectorySecurity.cs" />
<Compile Include="System\DirectoryServices\AdsVLV.cs" />
<Compile Include="System\DirectoryServices\AuthenticationTypes.cs" />

View File

@@ -1 +1 @@
5512312aa6bdb5e8a2c4476128f22895f08223b0
ae29ccfeed9ec00c81f609fdf9c8082cf736dc26

View File

@@ -398,7 +398,7 @@ namespace System.DirectoryServices
public bool Asynchronous { get; set; }
/// <devdoc>
/// Gets or sets a value indicateing whether the search should also return deleted objects that match the search
/// Gets or sets a value indicating whether the search should also return deleted objects that match the search
/// filter.
/// </devdoc>
[DefaultValue(false)]

View File

@@ -10,7 +10,7 @@ namespace System.DirectoryServices
public enum ReferralChasingOption
{
/// <devdoc>
/// Never chase the referred-to server. Setthing this option
/// Never chase the referred-to server. Setting this option
/// prevents a client from contacting other servers in a referral process.
/// </devdoc>
None = 0,

View File

@@ -148,7 +148,7 @@ namespace System.DirectoryServices
}
/// <devdoc>
/// nserts an item at the specified position in the collection.
/// Inserts an item at the specified position in the collection.
/// </devdoc>
public void Insert(int index, string value)
{

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
To enable the tests marked with [ConditionalFact(nameof(IsLdapConfigurationExist))], need to setup LDAP server and provide the needed server info here.
The easiest way to get LDAP server is to download and install OpenDJ https://backstage.forgerock.com/downloads/OpenDJ/Directory%20Services/5.0.0#browse.
Download "DS zip" file then extract it. you can set it up by running a command like that following:
/setup directory-server --sampleData 2 --rootUserDN "cn=Directory Manager" --rootUserPassword password --hostname localhost.localdomain --ldapPort 1389 --ldapsPort 1636 --httpPort 8080 --httpsPort 8443 --adminConnectorPort 4444 --baseDN dc=example,dc=com --acceptLicense enableStartTls
After that delete this comment and have the following contents in this Xml file:
<Configuration>
<ServerName>server machine name</ServerName>
<Domain>DC=example,DC=com</Domain>
<Port>1389</Port>
<User>cn=Directory Manager</User>
<Password>password</Password>
<AuthenticationTypes>ServerBind,None</AuthenticationTypes>
</Configuration>
-->

View File

@@ -10,6 +10,7 @@
<Compile Include="System\DirectoryServices\ActiveDirectorySecurityTests.cs" />
<Compile Include="System\DirectoryServices\ActiveDirectory\DomainControllerTests.cs" />
<Compile Include="System\DirectoryServices\DirectoryEntryTests.cs" />
<Compile Include="System\DirectoryServices\DirectoryServicesTests.cs" />
<Compile Include="System\DirectoryServices\DirectorySynchronizationTests.cs" />
<Compile Include="System\DirectoryServices\DirectoryVirtualListViewContextTests.cs" />
<Compile Include="System\DirectoryServices\DirectoryVirtualListViewTests.cs" />
@@ -18,9 +19,21 @@
<Compile Include="System\DirectoryServices\ActiveDirectory\ActiveDirectoryInterSiteTransportTests.cs" />
<Compile Include="System\DirectoryServices\ActiveDirectory\DirectoryContextTests.cs" />
<Compile Include="System\DirectoryServices\ActiveDirectory\ForestTests.cs" />
<Compile Include="$(CommonTestPath)\System\PlatformDetection.cs">
<Link>Common\System\PlatformDetection.cs</Link>
<Compile Include="$(CommonTestPath)\System\DirectoryServices\LdapConfiguration.cs">
<Link>Common\DirectoryServices\LdapConfiguration.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="LDAP.Configuration.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup Condition="'$(TargetsWindows)' == 'true'" >
<Compile Include="System\DirectoryServices\DirectoryServicesTests.Windows.cs" />
<Compile Include="System\DirectoryServices\ActiveDirectoryComInterop.cs" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>

View File

@@ -36,8 +36,12 @@ namespace System.DirectoryServices.ActiveDirectory.Tests
[SkipOnTargetFramework(TargetFrameworkMonikers.Uap, "Not approved COM object for app")]
public void FindByTransportType_ForestNoDomainAssociatedWithName_ThrowsActiveDirectoryOperationException_NoUap()
{
var context = new DirectoryContext(DirectoryContextType.Forest, "\0");
AssertExtensions.Throws<ArgumentException>("context", () => ActiveDirectoryInterSiteTransport.FindByTransportType(context, ActiveDirectoryTransportType.Rpc));
// Domain joined machines will not throw on the ActiveDirectoryInterSiteTransport.FindByTransportType call.
if (Environment.MachineName.Equals(Environment.UserDomainName, StringComparison.OrdinalIgnoreCase))
{
var context = new DirectoryContext(DirectoryContextType.Forest, "\0");
AssertExtensions.Throws<ArgumentException>("context", () => ActiveDirectoryInterSiteTransport.FindByTransportType(context, ActiveDirectoryTransportType.Rpc));
}
}
[Fact]
@@ -47,7 +51,7 @@ namespace System.DirectoryServices.ActiveDirectory.Tests
AssertExtensions.Throws<ArgumentException>("context", () => ActiveDirectoryInterSiteTransport.FindByTransportType(context, ActiveDirectoryTransportType.Rpc));
}
[ConditionalTheory(nameof(PlatformDetection) + "." + nameof(PlatformDetection.IsNotWindowsNanoServer))]
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindowsNanoServer))]
[OuterLoop("Takes too long on domain joined machines")]
[InlineData(DirectoryContextType.ApplicationPartition)]
[InlineData(DirectoryContextType.DirectoryServer)]

View File

@@ -26,7 +26,7 @@ namespace System.DirectoryServices.ActiveDirectory.Tests
AssertExtensions.Throws<ArgumentException>("context", () => DomainController.GetDomainController(context));
}
[ConditionalTheory(nameof(PlatformDetection) + "." + nameof(PlatformDetection.IsNotWindowsNanoServer))]
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindowsNanoServer))]
[OuterLoop("Takes too long on domain joined machines")]
[InlineData("\0")]
[InlineData("server:port")]
@@ -38,7 +38,7 @@ namespace System.DirectoryServices.ActiveDirectory.Tests
Assert.Throws<ActiveDirectoryObjectNotFoundException>(() => DomainController.GetDomainController(context));
}
[ConditionalFact(nameof(PlatformDetection) + "." + nameof(PlatformDetection.IsNotWindowsNanoServer))]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindowsNanoServer))]
[SkipOnTargetFramework(TargetFrameworkMonikers.Uap, "Access to path is denied when in App container")]
public void GetDomainController_InvalidIPV6_ThrowsActiveDirectoryObjectNotFoundException()
{
@@ -109,9 +109,13 @@ namespace System.DirectoryServices.ActiveDirectory.Tests
[SkipOnTargetFramework(TargetFrameworkMonikers.Uap, "Not approved COM object for app")]
public void FindAll_NoSuchName_ReturnsEmpty()
{
var context = new DirectoryContext(DirectoryContextType.Domain, "\0");
Assert.Empty(DomainController.FindAll(context));
Assert.Empty(DomainController.FindAll(context, "siteName"));
// Domain joined machines can have entries in the DomainController.
if (Environment.MachineName.Equals(Environment.UserDomainName, StringComparison.OrdinalIgnoreCase))
{
var context = new DirectoryContext(DirectoryContextType.Domain, "\0");
Assert.Empty(DomainController.FindAll(context));
Assert.Empty(DomainController.FindAll(context, "siteName"));
}
}
[Fact]

View File

@@ -33,7 +33,7 @@ namespace System.DirectoryServices.ActiveDirectory.Tests
Assert.Throws<ActiveDirectoryOperationException>(() => Forest.GetForest(context));
}
[ConditionalTheory(nameof(PlatformDetection) + "." + nameof(PlatformDetection.IsNotWindowsNanoServer))]
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindowsNanoServer))]
[InlineData(DirectoryContextType.DirectoryServer, "\0")]
[InlineData(DirectoryContextType.Forest, "server:port")]
[ActiveIssue("https://github.com/dotnet/corefx/issues/21553", TargetFrameworkMonikers.UapAot)]
@@ -46,7 +46,7 @@ namespace System.DirectoryServices.ActiveDirectory.Tests
Assert.Throws<ActiveDirectoryObjectNotFoundException>(() => Forest.GetForest(context));
}
[ConditionalTheory(nameof(PlatformDetection) + "." + nameof(PlatformDetection.IsNotWindowsNanoServer))]
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindowsNanoServer))]
[OuterLoop("Takes too long on domain joined machines")]
[InlineData(DirectoryContextType.Forest, "\0")]
[InlineData(DirectoryContextType.DirectoryServer, "server:port")]

View File

@@ -0,0 +1,257 @@
// Licensed to the .NET Foundation under one or more agreements.
// 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.CompilerServices;
using System.Runtime.InteropServices;
using System;
namespace ActiveDirectoryComInterop
{
// , TypeLibType(TypeLibTypeFlags.FDual | TypeLibTypeFlags.FDispatchable)
[Guid("9068270B-0939-11D1-8BE1-00C04FD8D503")]
[ComImport]
public interface IADsLargeInteger
{
[DispId(2)]
int HighPart
{
[DispId(2)]
[MethodImpl(MethodImplOptions.InternalCall)]
get;
[DispId(2)]
[MethodImpl(MethodImplOptions.InternalCall)]
set;
}
[DispId(3)]
int LowPart
{
[DispId(3)]
[MethodImpl(MethodImplOptions.InternalCall)]
get;
[DispId(3)]
[MethodImpl(MethodImplOptions.InternalCall)]
set;
}
}
// , TypeLibType(TypeLibTypeFlags.FDual | TypeLibTypeFlags.FDispatchable)
[Guid("FD8256D0-FD15-11CE-ABC4-02608C9E7553")]
[ComImport]
public interface IADs
{
[DispId(2)]
string Name
{
[DispId(2)]
[MethodImpl(MethodImplOptions.InternalCall)]
[return: MarshalAs(UnmanagedType.BStr)]
get;
}
[DispId(3)]
string Class
{
[DispId(3)]
[MethodImpl(MethodImplOptions.InternalCall)]
[return: MarshalAs(UnmanagedType.BStr)]
get;
}
[DispId(4)]
string GUID
{
[DispId(4)]
[MethodImpl(MethodImplOptions.InternalCall)]
[return: MarshalAs(UnmanagedType.BStr)]
get;
}
[DispId(5)]
string ADsPath
{
[DispId(5)]
[MethodImpl(MethodImplOptions.InternalCall)]
[return: MarshalAs(UnmanagedType.BStr)]
get;
}
[DispId(6)]
string Parent
{
[DispId(6)]
[MethodImpl(MethodImplOptions.InternalCall)]
[return: MarshalAs(UnmanagedType.BStr)]
get;
}
[DispId(7)]
string Schema
{
[DispId(7)]
[MethodImpl(MethodImplOptions.InternalCall)]
[return: MarshalAs(UnmanagedType.BStr)]
get;
}
[DispId(8)]
[MethodImpl(MethodImplOptions.InternalCall)]
void GetInfo();
[DispId(9)]
[MethodImpl(MethodImplOptions.InternalCall)]
void SetInfo();
[DispId(10)]
[MethodImpl(MethodImplOptions.InternalCall)]
[return: MarshalAs(UnmanagedType.Struct)]
object Get([MarshalAs(UnmanagedType.BStr)] [In] string bstrName);
[DispId(11)]
[MethodImpl(MethodImplOptions.InternalCall)]
void Put([MarshalAs(UnmanagedType.BStr)] [In] string bstrName, [MarshalAs(UnmanagedType.Struct)] [In] object vProp);
[DispId(12)]
[MethodImpl(MethodImplOptions.InternalCall)]
[return: MarshalAs(UnmanagedType.Struct)]
object GetEx([MarshalAs(UnmanagedType.BStr)] [In] string bstrName);
[DispId(13)]
[MethodImpl(MethodImplOptions.InternalCall)]
void PutEx([In] int lnControlCode, [MarshalAs(UnmanagedType.BStr)] [In] string bstrName, [MarshalAs(UnmanagedType.Struct)] [In] object vProp);
[DispId(14)]
[MethodImpl(MethodImplOptions.InternalCall)]
void GetInfoEx([MarshalAs(UnmanagedType.Struct)] [In] object vProperties, [In] int lnReserved);
}
// , TypeLibType(TypeLibTypeFlags.FDual | TypeLibTypeFlags.FDispatchable)
[Guid("B8C787CA-9BDD-11D0-852C-00C04FD8D503")]
[ComImport]
public interface IADsSecurityDescriptor
{
[DispId(2)]
int Revision
{
[DispId(2)]
[MethodImpl(MethodImplOptions.InternalCall)]
get;
[DispId(2)]
[MethodImpl(MethodImplOptions.InternalCall)]
set;
}
[DispId(3)]
int Control
{
[DispId(3)]
[MethodImpl(MethodImplOptions.InternalCall)]
get;
[DispId(3)]
[MethodImpl(MethodImplOptions.InternalCall)]
set;
}
[DispId(4)]
string Owner
{
[DispId(4)]
[MethodImpl(MethodImplOptions.InternalCall)]
[return: MarshalAs(UnmanagedType.BStr)]
get;
[DispId(4)]
[MethodImpl(MethodImplOptions.InternalCall)]
[param: MarshalAs(UnmanagedType.BStr)]
set;
}
[DispId(5)]
bool OwnerDefaulted
{
[DispId(5)]
[MethodImpl(MethodImplOptions.InternalCall)]
get;
[DispId(5)]
[MethodImpl(MethodImplOptions.InternalCall)]
set;
}
[DispId(6)]
string Group
{
[DispId(6)]
[MethodImpl(MethodImplOptions.InternalCall)]
[return: MarshalAs(UnmanagedType.BStr)]
get;
[DispId(6)]
[MethodImpl(MethodImplOptions.InternalCall)]
[param: MarshalAs(UnmanagedType.BStr)]
set;
}
[DispId(7)]
bool GroupDefaulted
{
[DispId(7)]
[MethodImpl(MethodImplOptions.InternalCall)]
get;
[DispId(7)]
[MethodImpl(MethodImplOptions.InternalCall)]
set;
}
[DispId(8)]
object DiscretionaryAcl
{
[DispId(8)]
[MethodImpl(MethodImplOptions.InternalCall)]
[return: MarshalAs(UnmanagedType.IDispatch)]
get;
[DispId(8)]
[MethodImpl(MethodImplOptions.InternalCall)]
[param: MarshalAs(UnmanagedType.IDispatch)]
set;
}
[DispId(9)]
bool DaclDefaulted
{
[DispId(9)]
[MethodImpl(MethodImplOptions.InternalCall)]
get;
[DispId(9)]
[MethodImpl(MethodImplOptions.InternalCall)]
set;
}
[DispId(10)]
object SystemAcl
{
[DispId(10)]
[MethodImpl(MethodImplOptions.InternalCall)]
[return: MarshalAs(UnmanagedType.IDispatch)]
get;
[DispId(10)]
[MethodImpl(MethodImplOptions.InternalCall)]
[param: MarshalAs(UnmanagedType.IDispatch)]
set;
}
[DispId(11)]
bool SaclDefaulted
{
[DispId(11)]
[MethodImpl(MethodImplOptions.InternalCall)]
get;
[DispId(11)]
[MethodImpl(MethodImplOptions.InternalCall)]
set;
}
[DispId(12)]
[MethodImpl(MethodImplOptions.InternalCall)]
[return: MarshalAs(UnmanagedType.IDispatch)]
object CopySecurityDescriptor();
}
}

View File

@@ -140,7 +140,7 @@ namespace System.DirectoryServices.Tests
Assert.Throws<ObjectDisposedException>(() => entry.CopyTo(disposedEntry, "newName"));
}
[ConditionalFact(nameof(PlatformDetection) + "." + nameof(PlatformDetection.IsNotWindowsNanoServer))]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindowsNanoServer))]
[ActiveIssue(21346, TargetFrameworkMonikers.UapAot)]
public void DeleteTree_NoObject_ThrowsCOMException()
{

View File

@@ -0,0 +1,54 @@
// Licensed to the .NET Foundation under one or more agreements.
// 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;
using System.Collections.Generic;
using System.Collections;
using Xunit;
using ActiveDirectoryComInterop;
namespace System.DirectoryServices.Tests
{
public partial class DirectoryServicesTests
{
[ConditionalFact(nameof(IsActiveDirectoryServer))]
public void TestComInterfaces()
{
using (DirectoryEntry de = CreateRootEntry())
{
DeleteOU(de, "dateRoot");
try
{
using (DirectoryEntry rootOU = CreateOU(de, "dateRoot", "Date OU"))
{
long deTime = GetTimeValue((IADsLargeInteger) de.Properties["uSNCreated"].Value);
long rootOUTime = GetTimeValue((IADsLargeInteger) rootOU.Properties["uSNCreated"].Value);
// we are sure rootOU is created after de
Assert.True(rootOUTime > deTime);
IADs iads = (IADs) rootOU.NativeObject;
Assert.Equal("ou=dateRoot", iads.Name);
Assert.Equal("Class", iads.Class);
Assert.True(iads.ADsPath.IndexOf(LdapConfiguration.Configuration.ServerName, StringComparison.OrdinalIgnoreCase) >= 0);
IADsSecurityDescriptor iadsSD = (IADsSecurityDescriptor) de.Properties["ntSecurityDescriptor"].Value;
Assert.True(LdapConfiguration.Configuration.Domain.IndexOf(iadsSD.Owner.Split('\\')[0], StringComparison.OrdinalIgnoreCase) >= 0);
Assert.True(LdapConfiguration.Configuration.Domain.IndexOf(iadsSD.Group.Split('\\')[0], StringComparison.OrdinalIgnoreCase) >= 0);
}
}
finally
{
DeleteOU(de, "dateRoot");
}
}
}
private long GetTimeValue(IADsLargeInteger largeInteger)
{
return (long) largeInteger.LowPart | (long) (largeInteger.HighPart << 32);
}
}
}