├── .gitignore
├── .vscode
├── launch.json
├── settings.json
└── tasks.json
├── README.md
├── System.DirectoryServices.Protocols.sln
├── src
├── ConsoleTestApp
│ ├── ConsoleTestApp.csproj
│ ├── Program.cs
│ └── appsettings.json
└── System.DirectoryServices.Protocols
│ ├── Program.cs
│ ├── Resources
│ ├── Strings.Designer.cs
│ └── Strings.resx
│ ├── System.DirectoryServices.Protocols.csproj
│ └── System
│ └── DirectoryServices
│ └── Protocols
│ ├── common
│ ├── AuthTypes.cs
│ ├── BerConverter.cs
│ ├── DereferenceAlias.cs
│ ├── DirectoryAttribute.cs
│ ├── DirectoryAttributeOperation.cs
│ ├── DirectoryConnection.cs
│ ├── DirectoryControl.cs
│ ├── DirectoryException.cs
│ ├── DirectoryIdentifier.cs
│ ├── DirectoryOperation.cs
│ ├── DirectoryRequest.cs
│ ├── DirectoryResponse.cs
│ ├── PartialResultsCollection.cs
│ ├── ReferralChasingOption.cs
│ ├── ResultCode.cs
│ ├── SearchResults.cs
│ ├── SearchScope.cs
│ ├── encoding.Unix.cs
│ ├── encoding.Windows.cs
│ └── utils.cs
│ └── ldap
│ ├── LdapAsyncResult.cs
│ ├── LdapConnection.cs
│ ├── LdapDirectoryIdentifier.cs
│ ├── LdapException.cs
│ ├── LdapPartialResultsProcessor.cs
│ ├── LdapSessionOptions.Unix.cs
│ ├── LdapSessionOptions.Windows.cs
│ ├── LdapSessionOptions.cs
│ ├── SafeHandles.cs
│ └── Wldap32UnsafeMethods.cs
└── tests
├── AddRequestTests.cs
├── AsqRequestControlTests.cs
├── BerConversionExceptionTests.cs
├── BerConverterTests.cs
├── CompareRequestTests.cs
├── Configurations.props
├── CoreFx.Private.TestUtilities
└── AssertExtensions.cs
├── CrossDomainMoveControlTests.cs
├── DeleteRequestTests.cs
├── DirSyncRequestControlTests.cs
├── DirectoryAttributeCollectionTests.cs
├── DirectoryAttributeModificationCollectionTests.cs
├── DirectoryAttributeModificationTests.cs
├── DirectoryAttributeTests.cs
├── DirectoryConnectionTests.cs
├── DirectoryControlCollectionTests.cs
├── DirectoryControlTests.cs
├── DirectoryExceptionTests.cs
├── DirectoryNotificationControlTests.cs
├── DirectoryOperationExceptionTests.cs
├── DirectoryServices
└── LdapConfiguration.cs
├── DirectoryServicesProtocolsTests.cs
├── DomainScopeControlTests.cs
├── DsmlAuthRequestTests.cs
├── ExtendedDNControlTests.cs
├── ExtendedRequestTests.cs
├── LDAP.Configuration.xml
├── LazyCommitControlTests.cs
├── LdapConnectionTests.cs
├── LdapDirectoryIdentifierTests.cs
├── LdapExceptionTests.cs
├── LdapSessionOptionsTests.cs
├── ModifyDNRequestTests.cs
├── ModifyRequestTests.cs
├── PageResultRequestControlTests.cs
├── PermissiveModifyControlTests.cs
├── QuotaControlTests.cs
├── ReferralCallbackTests.cs
├── SearchOptionsControlTests.cs
├── SearchRequestTests.cs
├── SecurityDescriptorFlagControlTests.cs
├── ShowDeletedControlTests.cs
├── SortKeyTests.cs
├── SortRequestControlTests.cs
├── System.DirectoryServices.Protocols.Tests.csproj
├── TlsOperationExceptionTests.cs
├── TreeDeleteControlTests.cs
├── VerifyNameControlTests.cs
├── VlvRequestControlTests.cs
└── xunit.netcore.extensions
├── Attributes
├── ActiveIssueAttribute.cs
├── ConditionalFactAttribute.cs
└── SkipOnTargetFrameworkAttribute.cs
├── Discoverers
├── ConditionalFactDiscoverer .cs
└── ConditionalTestDiscoverer.cs
├── SkippedTestCase.cs
├── TargetFrameworkMonikers.cs
└── TestPlatforms.cs
/.gitignore:
--------------------------------------------------------------------------------
1 | # Build results
2 | [Dd]ebug/
3 | [Dd]ebugPublic/
4 | [Rr]elease/
5 | [Rr]eleases/
6 | x64/
7 | x86/
8 | build/
9 | bld/
10 | [Bb]in/
11 | [Oo]bj/
12 | [Oo]ut/
13 | msbuild.log
14 | msbuild.err
15 | msbuild.wrn
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to find out which attributes exist for C# debugging
3 | // Use hover for the description of the existing attributes
4 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": ".NET Core Launch (console)",
9 | "type": "coreclr",
10 | "request": "launch",
11 | "preLaunchTask": "build",
12 | // If you have changed target frameworks, make sure to update the program path.
13 | "program": "${workspaceFolder}/src/ConsoleTestApp/bin/Debug/netcoreapp2.1/ConsoleTestApp.dll",
14 | "args": [],
15 | "cwd": "${workspaceFolder}/src/ConsoleTestApp",
16 | // For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window
17 | "console": "internalConsole",
18 | "stopAtEntry": false,
19 | "internalConsoleOptions": "openOnSessionStart"
20 | },
21 | {
22 | "name": ".NET Core Attach",
23 | "type": "coreclr",
24 | "request": "attach",
25 | "processId": "${command:pickProcess}"
26 | }
27 | ,]
28 | }
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "todo-tree.tags": [
3 | "TODO",
4 | "FIXME",
5 | "NOTE"
6 | ]
7 | }
--------------------------------------------------------------------------------
/.vscode/tasks.json:
--------------------------------------------------------------------------------
1 | {
2 | // See https://go.microsoft.com/fwlink/?LinkId=733558
3 | // for the documentation about the tasks.json format
4 | "version": "2.0.0",
5 | "tasks": [
6 | {
7 | "label": "build",
8 | "command": "dotnet",
9 | "args": [
10 | "build",
11 | "/p:GenerateFullPaths=true"
12 | ],
13 | "type": "shell",
14 | "group": "build",
15 | "presentation": {
16 | "reveal": "silent"
17 | },
18 | "problemMatcher": "$msCompile"
19 | },
20 | {
21 | "label": "test",
22 | "command": "dotnet",
23 | "type": "process",
24 | "args": [
25 | "test",
26 | "/p:GenerateFullPaths=true",
27 | "${workspaceFolder}/tests/System.DirectoryServices.Protocols.Tests.csproj",
28 | ],
29 | "problemMatcher": "$msCompile",
30 | "group": {
31 | "kind": "test",
32 | "isDefault": true
33 | }
34 | },
35 |
36 |
37 | ]
38 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## Summary
2 |
3 | **Proof-Of-Concept** port of core-fx "System.DirectoryServices.Protocols" to Linux (using libldap)
4 |
5 | The ideal port would be fully managed of course, but unfortunately isn't here (yet?), so for the time being...
6 |
7 |
8 | ## Nuget
9 |
10 | [https://www.nuget.org/packages/S.DS.P.linux](https://www.nuget.org/packages/S.DS.P.linux/)
11 |
12 |
13 | ## Prerequisites
14 |
15 | * Linux (obviously)
16 |
17 | * .NET Core 2.1(+)
18 |
19 | * libldap
20 |
21 | ## What isn't working / known issues
22 | * Most of the SessionOptions aren't implemented
23 | * Referrals are not implemented
24 | * Only Anonymous and Basic authentication are work
25 | * No LDAPS, but StartTransportLayerSecurity works
26 |
27 |
28 | ## Tested
29 |
30 | * Debian 9-x64, .NET Core SDK 2.1.300, libldap-2.4-2
31 | * Directories:
32 | * 389 Directory Server (1.3.4.0)
33 | * Active Directory (2012 R2)
34 |
35 |
36 | ## Disclaimer
37 |
38 | Quick (and somewhat dirty) port that suits my personal needs and might serve yours.
39 | **Use at your onwn risk**
40 |
41 |
42 |
43 |
44 |
45 | ## Relevant github issue
46 |
47 | [Support System.DirectoryServices.Protocols on Linux/Mac #24843](https://github.com/dotnet/corefx/issues/24843)
48 |
49 |
--------------------------------------------------------------------------------
/System.DirectoryServices.Protocols.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.26124.0
5 | MinimumVisualStudioVersion = 15.0.26124.0
6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{64AF1C61-1379-4190-A890-254EC77AC449}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.DirectoryServices.Protocols", "src\System.DirectoryServices.Protocols\System.DirectoryServices.Protocols.csproj", "{6D36F705-495A-4956-9CEA-9AB09345E5B2}"
9 | EndProject
10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.DirectoryServices.Protocols.Tests", "tests\System.DirectoryServices.Protocols.Tests.csproj", "{9F7796C5-2846-46E3-9245-5885D2526A07}"
11 | EndProject
12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleTestApp", "src\ConsoleTestApp\ConsoleTestApp.csproj", "{A8353C87-3788-41DB-AD7A-D657A2976D26}"
13 | EndProject
14 | Global
15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
16 | Debug|Any CPU = Debug|Any CPU
17 | Debug|x64 = Debug|x64
18 | Debug|x86 = Debug|x86
19 | Release|Any CPU = Release|Any CPU
20 | Release|x64 = Release|x64
21 | Release|x86 = Release|x86
22 | EndGlobalSection
23 | GlobalSection(SolutionProperties) = preSolution
24 | HideSolutionNode = FALSE
25 | EndGlobalSection
26 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
27 | {6D36F705-495A-4956-9CEA-9AB09345E5B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
28 | {6D36F705-495A-4956-9CEA-9AB09345E5B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
29 | {6D36F705-495A-4956-9CEA-9AB09345E5B2}.Debug|x64.ActiveCfg = Debug|Any CPU
30 | {6D36F705-495A-4956-9CEA-9AB09345E5B2}.Debug|x64.Build.0 = Debug|Any CPU
31 | {6D36F705-495A-4956-9CEA-9AB09345E5B2}.Debug|x86.ActiveCfg = Debug|Any CPU
32 | {6D36F705-495A-4956-9CEA-9AB09345E5B2}.Debug|x86.Build.0 = Debug|Any CPU
33 | {6D36F705-495A-4956-9CEA-9AB09345E5B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
34 | {6D36F705-495A-4956-9CEA-9AB09345E5B2}.Release|Any CPU.Build.0 = Release|Any CPU
35 | {6D36F705-495A-4956-9CEA-9AB09345E5B2}.Release|x64.ActiveCfg = Release|Any CPU
36 | {6D36F705-495A-4956-9CEA-9AB09345E5B2}.Release|x64.Build.0 = Release|Any CPU
37 | {6D36F705-495A-4956-9CEA-9AB09345E5B2}.Release|x86.ActiveCfg = Release|Any CPU
38 | {6D36F705-495A-4956-9CEA-9AB09345E5B2}.Release|x86.Build.0 = Release|Any CPU
39 | {9F7796C5-2846-46E3-9245-5885D2526A07}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
40 | {9F7796C5-2846-46E3-9245-5885D2526A07}.Debug|Any CPU.Build.0 = Debug|Any CPU
41 | {9F7796C5-2846-46E3-9245-5885D2526A07}.Debug|x64.ActiveCfg = Debug|Any CPU
42 | {9F7796C5-2846-46E3-9245-5885D2526A07}.Debug|x64.Build.0 = Debug|Any CPU
43 | {9F7796C5-2846-46E3-9245-5885D2526A07}.Debug|x86.ActiveCfg = Debug|Any CPU
44 | {9F7796C5-2846-46E3-9245-5885D2526A07}.Debug|x86.Build.0 = Debug|Any CPU
45 | {9F7796C5-2846-46E3-9245-5885D2526A07}.Release|Any CPU.ActiveCfg = Release|Any CPU
46 | {9F7796C5-2846-46E3-9245-5885D2526A07}.Release|Any CPU.Build.0 = Release|Any CPU
47 | {9F7796C5-2846-46E3-9245-5885D2526A07}.Release|x64.ActiveCfg = Release|Any CPU
48 | {9F7796C5-2846-46E3-9245-5885D2526A07}.Release|x64.Build.0 = Release|Any CPU
49 | {9F7796C5-2846-46E3-9245-5885D2526A07}.Release|x86.ActiveCfg = Release|Any CPU
50 | {9F7796C5-2846-46E3-9245-5885D2526A07}.Release|x86.Build.0 = Release|Any CPU
51 | {A8353C87-3788-41DB-AD7A-D657A2976D26}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
52 | {A8353C87-3788-41DB-AD7A-D657A2976D26}.Debug|Any CPU.Build.0 = Debug|Any CPU
53 | {A8353C87-3788-41DB-AD7A-D657A2976D26}.Debug|x64.ActiveCfg = Debug|Any CPU
54 | {A8353C87-3788-41DB-AD7A-D657A2976D26}.Debug|x64.Build.0 = Debug|Any CPU
55 | {A8353C87-3788-41DB-AD7A-D657A2976D26}.Debug|x86.ActiveCfg = Debug|Any CPU
56 | {A8353C87-3788-41DB-AD7A-D657A2976D26}.Debug|x86.Build.0 = Debug|Any CPU
57 | {A8353C87-3788-41DB-AD7A-D657A2976D26}.Release|Any CPU.ActiveCfg = Release|Any CPU
58 | {A8353C87-3788-41DB-AD7A-D657A2976D26}.Release|Any CPU.Build.0 = Release|Any CPU
59 | {A8353C87-3788-41DB-AD7A-D657A2976D26}.Release|x64.ActiveCfg = Release|Any CPU
60 | {A8353C87-3788-41DB-AD7A-D657A2976D26}.Release|x64.Build.0 = Release|Any CPU
61 | {A8353C87-3788-41DB-AD7A-D657A2976D26}.Release|x86.ActiveCfg = Release|Any CPU
62 | {A8353C87-3788-41DB-AD7A-D657A2976D26}.Release|x86.Build.0 = Release|Any CPU
63 | EndGlobalSection
64 | GlobalSection(NestedProjects) = preSolution
65 | {6D36F705-495A-4956-9CEA-9AB09345E5B2} = {64AF1C61-1379-4190-A890-254EC77AC449}
66 | {A8353C87-3788-41DB-AD7A-D657A2976D26} = {64AF1C61-1379-4190-A890-254EC77AC449}
67 | EndGlobalSection
68 | EndGlobal
69 |
--------------------------------------------------------------------------------
/src/ConsoleTestApp/ConsoleTestApp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp2.1
6 | consoletestapp-eb00853f-de89-4222-a3ec-7083267dd9d0
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/ConsoleTestApp/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using Microsoft.Extensions.Configuration;
4 | using System.Collections.Generic;
5 | using System.DirectoryServices.Protocols;
6 | using System.Security.Cryptography.X509Certificates;
7 |
8 |
9 | namespace ConsoleTestApp
10 | {
11 | class Program
12 | {
13 | public static IConfiguration Configuration { get; private set; }
14 |
15 | public class LdapDirectoryConfiguration
16 | {
17 | public string[] Server { get; set; }
18 | public int PortNumber { get; set; } = 389;
19 | public AuthType AuthType { get; set; }
20 | public string BindDn { get; set; }
21 | public string BindPasswordUserSecret { get; set; }
22 | public System.Net.NetworkCredential NetworkCredential
23 | {
24 | get
25 | {
26 | if (!string.IsNullOrEmpty(BindDn))
27 | {
28 | return new System.Net.NetworkCredential(BindDn, Configuration[BindPasswordUserSecret]);
29 | }
30 | else
31 | {
32 | return null;
33 | }
34 | }
35 | }
36 | public LdapDirectoryIdentifier LdapDirectoryIdentifier
37 | {
38 | get
39 | {
40 | return new LdapDirectoryIdentifier(Server, PortNumber, false, false);
41 | }
42 | }
43 | }
44 |
45 | public static bool VerifyServerCertificateCallback(LdapConnection connection, X509Certificate certificate)
46 | {
47 | Console.WriteLine();
48 | return true;
49 | }
50 |
51 | static void Main(string[] args)
52 | {
53 | Configuration = new ConfigurationBuilder()
54 | .SetBasePath(Directory.GetCurrentDirectory())
55 | .AddJsonFile("appsettings.json", true)
56 | .AddEnvironmentVariables()
57 | .AddUserSecrets("consoletestapp-eb00853f-de89-4222-a3ec-7083267dd9d0")
58 | .Build();
59 |
60 | // var ldapident = new LdapDirectoryIdentifier("bl18-05.internal.uzgent.be", 389, false, false);
61 |
62 | //var ldapident = new LdapDirectoryIdentifier("ai.internal.uzgent.be", 389, false, false);
63 |
64 | var directoryConfigurations = Configuration.GetSection("DirectoryConfigurations").Get>();
65 | var activeConfiguration = directoryConfigurations["AD"];
66 |
67 | var ldapDirectoryIdentifier = activeConfiguration.LdapDirectoryIdentifier;
68 | var networkCredential = activeConfiguration.NetworkCredential;
69 | var authType = activeConfiguration.AuthType;
70 |
71 |
72 | LdapConnection ldapConnection = new LdapConnection(ldapDirectoryIdentifier, networkCredential, authType);
73 |
74 | ldapConnection.SessionOptions.ProtocolVersion = 3;
75 |
76 | ldapConnection.SessionOptions.StartTransportLayerSecurity(new DirectoryControlCollection());
77 | ldapConnection.Bind(networkCredential);
78 |
79 |
80 | //var sRequest = new SearchRequest("ou=persoon,dc=internal,dc=uzgent,dc=be", "uzguid=bve", SearchScope.OneLevel, new String[] { "dn", "cn", "mobile", "jpegPhoto" });
81 | var sRequest = new SearchRequest("OU=LDAP,OU=UZUsers,DC=ai,DC=internal,DC=uzgent,DC=be", "employeeNumber=32233", SearchScope.Subtree, new String[] { "dn", "cn", "mobile", "jpegPhoto" });
82 |
83 | var sResponse = ldapConnection.SendRequest(sRequest) as SearchResponse;
84 |
85 | foreach (SearchResultEntry entry in sResponse.Entries)
86 | {
87 |
88 | string foundDN = entry.DistinguishedName;
89 |
90 | Console.WriteLine("Found: " + foundDN);
91 |
92 | Console.WriteLine(" |-> " + entry.Attributes["cn"][0].ToString());
93 |
94 | Console.WriteLine(" |-> " + entry.Attributes["mobile"]?[0].ToString() ?? "");
95 |
96 | var pic = entry.Attributes["jpegPhoto"]?.GetValues(typeof(byte[]))[0];
97 |
98 | }
99 | }
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/src/ConsoleTestApp/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "DirectoriesOld": [{
3 | "Server": "uzgldap389",
4 | "PortNumber": 389
5 | }],
6 |
7 | "DirectoryConfigurations": {
8 | "AD": {
9 | "Server": ["vdc1p.ai.internal.uzgent.be"],
10 | "AuthType": "Basic",
11 | "BindDn": "bve@ai.internal.uzgent.be",
12 | "BindPasswordUserSecret": "employeeNumber=32233:userPassword"
13 | },
14 | "389DS": {
15 | "Server": ["uzgldap389.internal.uzgent.be"],
16 | "AuthType": "Basic",
17 | "BindDn": "employeeNumber=32233,ou=persoon,dc=internal,dc=uzgent,dc=be",
18 | "BindPasswordUserSecret": "employeeNumber=32233:userPassword"
19 | }
20 | }
21 |
22 | }
--------------------------------------------------------------------------------
/src/System.DirectoryServices.Protocols/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Diagnostics;
4 | using System.DirectoryServices.Protocols;
5 | using System.Runtime.InteropServices;
6 | using System.Text;
7 | using Microsoft.Win32.SafeHandles;
8 |
9 | namespace System.DirectoryServices.ProtocolsX
10 | {
11 |
12 | class Program
13 | {
14 |
15 | static void Main(string[] args)
16 | {
17 |
18 |
19 | }
20 | }//
21 | }
22 |
--------------------------------------------------------------------------------
/src/System.DirectoryServices.Protocols/System.DirectoryServices.Protocols.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netstandard2.0
6 | true
7 | true
8 | false
9 | false
10 | true
11 |
12 |
13 |
14 | S.DS.P.linux
15 | 0.0.2-alpha.2
16 | dogguts
17 | Proof of concept port of dotnet/corefx System.DirectoryServices.Protocols against libldap/openldap for Linux
18 | false
19 | ldap linux directory services
20 | https://github.com/dogguts/System.DirectoryServices.Protocol_linux
21 | Not even pre-pre-alpha. Don't even dare using this on a production environment.
22 | True
23 | True
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
--------------------------------------------------------------------------------
/src/System.DirectoryServices.Protocols/System/DirectoryServices/Protocols/common/AuthTypes.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 | // See the LICENSE file in the project root for more information.
4 |
5 | using System;
6 |
7 | namespace System.DirectoryServices.Protocols
8 | {
9 | public enum AuthType
10 | {
11 | Anonymous = 0,
12 | Basic = 1,
13 | Negotiate = 2,
14 | Ntlm = 3,
15 | Digest = 4,
16 | Sicily = 5,
17 | Dpa = 6,
18 | Msn = 7,
19 | External = 8,
20 | Kerberos = 9
21 | }
22 |
23 | public enum PartialResultProcessing
24 | {
25 | NoPartialResultSupport,
26 | ReturnPartialResults,
27 | ReturnPartialResultsAndNotifyCallback
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/System.DirectoryServices.Protocols/System/DirectoryServices/Protocols/common/DereferenceAlias.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 | // See the LICENSE file in the project root for more information.
4 |
5 | namespace System.DirectoryServices.Protocols
6 | {
7 | public enum DereferenceAlias
8 | {
9 | Never = 0,
10 | InSearching = 1,
11 | FindingBaseObject = 2,
12 | Always = 3
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/System.DirectoryServices.Protocols/System/DirectoryServices/Protocols/common/DirectoryAttributeOperation.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 | // See the LICENSE file in the project root for more information.
4 |
5 | namespace System.DirectoryServices.Protocols
6 | {
7 | public enum DirectoryAttributeOperation
8 | {
9 | Add = 0,
10 | Delete = 1,
11 | Replace = 2
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/System.DirectoryServices.Protocols/System/DirectoryServices/Protocols/common/DirectoryConnection.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 | // See the LICENSE file in the project root for more information.
4 |
5 | using System.Globalization;
6 | using System.Net;
7 | using System.Security.Cryptography.X509Certificates;
8 |
9 | namespace System.DirectoryServices.Protocols
10 | {
11 | public abstract class DirectoryConnection
12 | {
13 | internal NetworkCredential _directoryCredential;
14 | private X509CertificateCollection _certificatesCollection;
15 | internal TimeSpan _connectionTimeOut = new TimeSpan(0, 0, 30);
16 | internal DirectoryIdentifier _directoryIdentifier;
17 |
18 | protected DirectoryConnection() => _certificatesCollection = new X509CertificateCollection();
19 |
20 | public virtual DirectoryIdentifier Directory => _directoryIdentifier;
21 |
22 | public X509CertificateCollection ClientCertificates => _certificatesCollection;
23 |
24 | public virtual TimeSpan Timeout
25 | {
26 | get => _connectionTimeOut;
27 | set
28 | {
29 | if (value < TimeSpan.Zero)
30 | {
31 | throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.NoNegativeTimeLimit), nameof(value));
32 | }
33 |
34 | _connectionTimeOut = value;
35 | }
36 | }
37 |
38 | public virtual NetworkCredential Credential
39 | {
40 | set
41 | {
42 | _directoryCredential = (value != null) ? new NetworkCredential(value.UserName, value.Password, value.Domain) : null;
43 | }
44 | }
45 |
46 | public abstract DirectoryResponse SendRequest(DirectoryRequest request);
47 |
48 | internal NetworkCredential GetCredential() => _directoryCredential;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/System.DirectoryServices.Protocols/System/DirectoryServices/Protocols/common/DirectoryException.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 | // See the LICENSE file in the project root for more information.
4 |
5 | using System.Runtime.Serialization;
6 |
7 | namespace System.DirectoryServices.Protocols
8 | {
9 | [Serializable]
10 | [System.Runtime.CompilerServices.TypeForwardedFrom("System.DirectoryServices.Protocols, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
11 | public class DirectoryException : Exception
12 | {
13 | protected DirectoryException(SerializationInfo info, StreamingContext context) : base(info, context)
14 | {
15 | }
16 |
17 | public DirectoryException(string message, Exception inner) : base(message, inner)
18 | {
19 | }
20 |
21 | public DirectoryException(string message) : base(message)
22 | {
23 | }
24 |
25 | public DirectoryException() : base()
26 | {
27 | }
28 | }
29 |
30 | [Serializable]
31 | [System.Runtime.CompilerServices.TypeForwardedFrom("System.DirectoryServices.Protocols, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
32 | public class DirectoryOperationException : DirectoryException, ISerializable
33 | {
34 | protected DirectoryOperationException(SerializationInfo info, StreamingContext context) : base(info, context) { }
35 |
36 | public DirectoryOperationException() : base() { }
37 |
38 | public DirectoryOperationException(string message) : base(message) { }
39 |
40 | public DirectoryOperationException(string message, Exception inner) : base(message, inner) { }
41 |
42 | public DirectoryOperationException(DirectoryResponse response) : base(SR.DefaultOperationsError)
43 | {
44 | Response = response;
45 | }
46 |
47 | public DirectoryOperationException(DirectoryResponse response, string message) : base(message)
48 | {
49 | Response = response;
50 | }
51 |
52 | public DirectoryOperationException(DirectoryResponse response, string message, Exception inner) : base(message, inner)
53 | {
54 | Response = response;
55 | }
56 |
57 | public DirectoryResponse Response { get; internal set; }
58 | }
59 |
60 | [Serializable]
61 | [System.Runtime.CompilerServices.TypeForwardedFrom("System.DirectoryServices.Protocols, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
62 | public class BerConversionException : DirectoryException
63 | {
64 | protected BerConversionException(SerializationInfo info, StreamingContext context) : base(info, context) { }
65 |
66 | public BerConversionException() : base(SR.BerConversionError)
67 | {
68 | }
69 |
70 | public BerConversionException(string message) : base(message)
71 | {
72 | }
73 |
74 | public BerConversionException(string message, Exception inner) : base(message, inner)
75 | {
76 | }
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/src/System.DirectoryServices.Protocols/System/DirectoryServices/Protocols/common/DirectoryIdentifier.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 | // See the LICENSE file in the project root for more information.
4 |
5 | using System;
6 |
7 | namespace System.DirectoryServices.Protocols
8 | {
9 | public abstract class DirectoryIdentifier
10 | {
11 | protected DirectoryIdentifier()
12 | {
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/System.DirectoryServices.Protocols/System/DirectoryServices/Protocols/common/DirectoryOperation.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 | // See the LICENSE file in the project root for more information.
4 |
5 | namespace System.DirectoryServices.Protocols
6 | {
7 | public abstract class DirectoryOperation
8 | {
9 | internal string _directoryRequestID;
10 |
11 | protected DirectoryOperation() { }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/System.DirectoryServices.Protocols/System/DirectoryServices/Protocols/common/DirectoryResponse.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 | // See the LICENSE file in the project root for more information.
4 |
5 | namespace System.DirectoryServices.Protocols
6 | {
7 | public abstract class DirectoryResponse : DirectoryOperation
8 | {
9 | private DirectoryControl[] _directoryControls;
10 | internal Uri[] _directoryReferral;
11 |
12 | internal DirectoryResponse(string dn, DirectoryControl[] controls, ResultCode result, string message, Uri[] referral)
13 | {
14 | MatchedDN = dn;
15 | _directoryControls = controls;
16 | ResultCode = result;
17 | ErrorMessage = message;
18 | _directoryReferral = referral;
19 | }
20 |
21 | public string RequestId { get; }
22 |
23 | public virtual string MatchedDN { get; }
24 |
25 | public virtual DirectoryControl[] Controls
26 | {
27 | get
28 | {
29 | if (_directoryControls == null)
30 | {
31 | return Array.Empty();
32 | }
33 |
34 | DirectoryControl[] tempControls = new DirectoryControl[_directoryControls.Length];
35 | for (int i = 0; i < _directoryControls.Length; i++)
36 | {
37 | tempControls[i] = new DirectoryControl(_directoryControls[i].Type, _directoryControls[i].GetValue(), _directoryControls[i].IsCritical, _directoryControls[i].ServerSide);
38 | }
39 | DirectoryControl.TransformControls(tempControls);
40 | return tempControls;
41 | }
42 | }
43 |
44 | public virtual ResultCode ResultCode { get; }
45 |
46 | public virtual string ErrorMessage { get; }
47 |
48 | public virtual Uri[] Referral
49 | {
50 | get
51 | {
52 | if (_directoryReferral == null)
53 | {
54 | return Array.Empty();
55 | }
56 |
57 | Uri[] tempReferral = new Uri[_directoryReferral.Length];
58 | for (int i = 0; i < _directoryReferral.Length; i++)
59 | {
60 | tempReferral[i] = new Uri(_directoryReferral[i].AbsoluteUri);
61 | }
62 | return tempReferral;
63 | }
64 | }
65 | }
66 |
67 | public class DeleteResponse : DirectoryResponse
68 | {
69 | internal DeleteResponse(string dn, DirectoryControl[] controls, ResultCode result, string message, Uri[] referral) : base(dn, controls, result, message, referral) { }
70 | }
71 |
72 | public class AddResponse : DirectoryResponse
73 | {
74 | internal AddResponse(string dn, DirectoryControl[] controls, ResultCode result, string message, Uri[] referral) : base(dn, controls, result, message, referral) { }
75 | }
76 |
77 | public class ModifyResponse : DirectoryResponse
78 | {
79 | internal ModifyResponse(string dn, DirectoryControl[] controls, ResultCode result, string message, Uri[] referral) : base(dn, controls, result, message, referral) { }
80 | }
81 |
82 | public class ModifyDNResponse : DirectoryResponse
83 | {
84 | internal ModifyDNResponse(string dn, DirectoryControl[] controls, ResultCode result, string message, Uri[] referral) : base(dn, controls, result, message, referral) { }
85 | }
86 |
87 | public class CompareResponse : DirectoryResponse
88 | {
89 | internal CompareResponse(string dn, DirectoryControl[] controls, ResultCode result, string message, Uri[] referral) : base(dn, controls, result, message, referral) { }
90 | }
91 |
92 | public class ExtendedResponse : DirectoryResponse
93 | {
94 | private byte[] _value;
95 |
96 | internal ExtendedResponse(string dn, DirectoryControl[] controls, ResultCode result, string message, Uri[] referral) : base(dn, controls, result, message, referral) { }
97 |
98 | public string ResponseName { get; internal set; }
99 |
100 | public byte[] ResponseValue
101 | {
102 | get
103 | {
104 | if (_value == null)
105 | {
106 | return Array.Empty();
107 | }
108 |
109 | byte[] tmpValue = new byte[_value.Length];
110 | for (int i = 0; i < _value.Length; i++)
111 | {
112 | tmpValue[i] = _value[i];
113 | }
114 | return tmpValue;
115 | }
116 | internal set => _value = value;
117 | }
118 | }
119 |
120 | public class SearchResponse : DirectoryResponse
121 | {
122 | private SearchResultReferenceCollection _referenceCollection = new SearchResultReferenceCollection();
123 | private SearchResultEntryCollection _entryCollection = new SearchResultEntryCollection();
124 | internal bool searchDone = false;
125 | internal SearchResponse(string dn, DirectoryControl[] controls, ResultCode result, string message, Uri[] referral) : base(dn, controls, result, message, referral) { }
126 |
127 | public SearchResultReferenceCollection References
128 | {
129 | get => _referenceCollection;
130 | internal set => _referenceCollection = value;
131 | }
132 |
133 | public SearchResultEntryCollection Entries
134 | {
135 | get => _entryCollection;
136 | internal set => _entryCollection = value;
137 | }
138 | }
139 | }
140 |
--------------------------------------------------------------------------------
/src/System.DirectoryServices.Protocols/System/DirectoryServices/Protocols/common/PartialResultsCollection.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 | // See the LICENSE file in the project root for more information.
4 |
5 | using System.Collections;
6 |
7 | namespace System.DirectoryServices.Protocols
8 | {
9 | public class PartialResultsCollection : ReadOnlyCollectionBase
10 | {
11 | internal PartialResultsCollection() { }
12 |
13 | public object this[int index] => InnerList[index];
14 |
15 | internal int Add(object value) => InnerList.Add(value);
16 |
17 | public bool Contains(object value) => InnerList.Contains(value);
18 |
19 | public int IndexOf(object value) => InnerList.IndexOf(value);
20 |
21 | public void CopyTo(object[] values, int index) => InnerList.CopyTo(values, index);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/System.DirectoryServices.Protocols/System/DirectoryServices/Protocols/common/ReferralChasingOption.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 | // See the LICENSE file in the project root for more information.
4 |
5 | namespace System.DirectoryServices.Protocols
6 | {
7 | [Flags]
8 | public enum ReferralChasingOptions
9 | {
10 | None = 0,
11 | Subordinate = 0x20,
12 | External = 0x40,
13 | All = Subordinate | External
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/System.DirectoryServices.Protocols/System/DirectoryServices/Protocols/common/ResultCode.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 | // See the LICENSE file in the project root for more information.
4 |
5 | using System.Collections.Generic;
6 |
7 | namespace System.DirectoryServices.Protocols
8 | {
9 | public enum ResultCode
10 | {
11 | Success = 0,
12 | OperationsError = 1,
13 | ProtocolError = 2,
14 | TimeLimitExceeded = 3,
15 | SizeLimitExceeded = 4,
16 | CompareFalse = 5,
17 | CompareTrue = 6,
18 | AuthMethodNotSupported = 7,
19 | StrongAuthRequired = 8,
20 | ReferralV2 = 9,
21 | Referral = 10,
22 | AdminLimitExceeded = 11,
23 | UnavailableCriticalExtension = 12,
24 | ConfidentialityRequired = 13,
25 | SaslBindInProgress = 14,
26 | NoSuchAttribute = 16,
27 | UndefinedAttributeType = 17,
28 | InappropriateMatching = 18,
29 | ConstraintViolation = 19,
30 | AttributeOrValueExists = 20,
31 | InvalidAttributeSyntax = 21,
32 | NoSuchObject = 32,
33 | AliasProblem = 33,
34 | InvalidDNSyntax = 34,
35 | AliasDereferencingProblem = 36,
36 | InappropriateAuthentication = 48,
37 | InsufficientAccessRights = 50,
38 | Busy = 51,
39 | Unavailable = 52,
40 | UnwillingToPerform = 53,
41 | LoopDetect = 54,
42 | SortControlMissing = 60,
43 | OffsetRangeError = 61,
44 | NamingViolation = 64,
45 | ObjectClassViolation = 65,
46 | NotAllowedOnNonLeaf = 66,
47 | NotAllowedOnRdn = 67,
48 | EntryAlreadyExists = 68,
49 | ObjectClassModificationsProhibited = 69,
50 | ResultsTooLarge = 70,
51 | AffectsMultipleDsas = 71,
52 | VirtualListViewError = 76,
53 | Other = 80
54 | }
55 |
56 | internal class OperationErrorMappings
57 | {
58 | private static readonly Dictionary s_resultCodeMapping = new Dictionary(capacity: 43)
59 | {
60 | { ResultCode.Success, SR.LDAP_SUCCESS },
61 | { ResultCode.OperationsError, SR.LDAP_OPERATIONS_ERROR },
62 | { ResultCode.ProtocolError, SR.LDAP_PROTOCOL_ERROR },
63 | { ResultCode.TimeLimitExceeded, SR.LDAP_TIMELIMIT_EXCEEDED },
64 | { ResultCode.SizeLimitExceeded, SR.LDAP_SIZELIMIT_EXCEEDED },
65 | { ResultCode.CompareFalse, SR.LDAP_COMPARE_FALSE },
66 | { ResultCode.CompareTrue, SR.LDAP_COMPARE_TRUE },
67 | { ResultCode.AuthMethodNotSupported, SR.LDAP_AUTH_METHOD_NOT_SUPPORTED },
68 | { ResultCode.StrongAuthRequired, SR.LDAP_STRONG_AUTH_REQUIRED },
69 | { ResultCode.ReferralV2, SR.LDAP_PARTIAL_RESULTS },
70 | { ResultCode.Referral, SR.LDAP_REFERRAL },
71 | { ResultCode.AdminLimitExceeded, SR.LDAP_ADMIN_LIMIT_EXCEEDED },
72 | { ResultCode.UnavailableCriticalExtension, SR.LDAP_UNAVAILABLE_CRIT_EXTENSION },
73 | { ResultCode.ConfidentialityRequired, SR.LDAP_CONFIDENTIALITY_REQUIRED },
74 | { ResultCode.SaslBindInProgress, SR.LDAP_SASL_BIND_IN_PROGRESS },
75 | { ResultCode.NoSuchAttribute, SR.LDAP_NO_SUCH_ATTRIBUTE },
76 | { ResultCode.UndefinedAttributeType, SR.LDAP_UNDEFINED_TYPE },
77 | { ResultCode.InappropriateMatching, SR.LDAP_INAPPROPRIATE_MATCHING },
78 | { ResultCode.ConstraintViolation, SR.LDAP_CONSTRAINT_VIOLATION },
79 | { ResultCode.AttributeOrValueExists, SR.LDAP_ATTRIBUTE_OR_VALUE_EXISTS },
80 | { ResultCode.InvalidAttributeSyntax, SR.LDAP_INVALID_SYNTAX },
81 | { ResultCode.NoSuchObject, SR.LDAP_NO_SUCH_OBJECT },
82 | { ResultCode.AliasProblem, SR.LDAP_ALIAS_PROBLEM },
83 | { ResultCode.InvalidDNSyntax, SR.LDAP_INVALID_DN_SYNTAX },
84 | { ResultCode.AliasDereferencingProblem, SR.LDAP_ALIAS_DEREF_PROBLEM },
85 | { ResultCode.InappropriateAuthentication, SR.LDAP_INAPPROPRIATE_AUTH },
86 | { ResultCode.InsufficientAccessRights, SR.LDAP_INSUFFICIENT_RIGHTS },
87 | { ResultCode.Busy, SR.LDAP_BUSY },
88 | { ResultCode.Unavailable, SR.LDAP_UNAVAILABLE },
89 | { ResultCode.UnwillingToPerform, SR.LDAP_UNWILLING_TO_PERFORM },
90 | { ResultCode.LoopDetect, SR.LDAP_LOOP_DETECT },
91 | { ResultCode.SortControlMissing, SR.LDAP_SORT_CONTROL_MISSING },
92 | { ResultCode.OffsetRangeError, SR.LDAP_OFFSET_RANGE_ERROR },
93 | { ResultCode.NamingViolation, SR.LDAP_NAMING_VIOLATION },
94 | { ResultCode.ObjectClassViolation, SR.LDAP_OBJECT_CLASS_VIOLATION },
95 | { ResultCode.NotAllowedOnNonLeaf, SR.LDAP_NOT_ALLOWED_ON_NONLEAF },
96 | { ResultCode.NotAllowedOnRdn, SR.LDAP_NOT_ALLOWED_ON_RDN },
97 | { ResultCode.EntryAlreadyExists, SR.LDAP_ALREADY_EXISTS },
98 | { ResultCode.ObjectClassModificationsProhibited, SR.LDAP_NO_OBJECT_CLASS_MODS },
99 | { ResultCode.ResultsTooLarge, SR.LDAP_RESULTS_TOO_LARGE },
100 | { ResultCode.AffectsMultipleDsas, SR.LDAP_AFFECTS_MULTIPLE_DSAS },
101 | { ResultCode.VirtualListViewError, SR.LDAP_VIRTUAL_LIST_VIEW_ERROR },
102 | { ResultCode.Other, SR.LDAP_OTHER }
103 | };
104 |
105 | public static string MapResultCode(int errorCode)
106 | {
107 | s_resultCodeMapping.TryGetValue((ResultCode)errorCode, out string errorMessage);
108 | return errorMessage;
109 | }
110 | }
111 |
112 | internal enum LdapOperation
113 | {
114 | LdapAdd = 0,
115 | LdapModify = 1,
116 | LdapSearch = 2,
117 | LdapDelete = 3,
118 | LdapModifyDn = 4,
119 | LdapCompare = 5,
120 | LdapExtendedRequest = 6
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/src/System.DirectoryServices.Protocols/System/DirectoryServices/Protocols/common/SearchResults.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 | // See the LICENSE file in the project root for more information.
4 |
5 | using System.Collections;
6 |
7 | namespace System.DirectoryServices.Protocols
8 | {
9 | public class SearchResultReference
10 | {
11 | private Uri[] _resultReferences;
12 | private DirectoryControl[] _resultControls;
13 |
14 | internal SearchResultReference(Uri[] uris) => _resultReferences = uris;
15 |
16 | public Uri[] Reference
17 | {
18 | get
19 | {
20 | if (_resultReferences == null)
21 | {
22 | return Array.Empty();
23 | }
24 |
25 | Uri[] tempUri = new Uri[_resultReferences.Length];
26 | for (int i = 0; i < _resultReferences.Length; i++)
27 | {
28 | tempUri[i] = new Uri(_resultReferences[i].AbsoluteUri);
29 | }
30 | return tempUri;
31 | }
32 | }
33 |
34 | public DirectoryControl[] Controls
35 | {
36 | get
37 | {
38 | if (_resultControls == null)
39 | {
40 | return Array.Empty();
41 | }
42 |
43 | DirectoryControl[] controls = new DirectoryControl[_resultControls.Length];
44 | for (int i = 0; i < _resultControls.Length; i++)
45 | {
46 | controls[i] = new DirectoryControl(_resultControls[i].Type, _resultControls[i].GetValue(), _resultControls[i].IsCritical, _resultControls[i].ServerSide);
47 | }
48 | DirectoryControl.TransformControls(controls);
49 | return controls;
50 | }
51 | }
52 | }
53 |
54 | public class SearchResultReferenceCollection : ReadOnlyCollectionBase
55 | {
56 | internal SearchResultReferenceCollection() { }
57 |
58 | public SearchResultReference this[int index] => (SearchResultReference)InnerList[index];
59 |
60 | internal int Add(SearchResultReference reference) => InnerList.Add(reference);
61 |
62 | public bool Contains(SearchResultReference value) => InnerList.Contains(value);
63 |
64 | public int IndexOf(SearchResultReference value) => InnerList.IndexOf(value);
65 |
66 | public void CopyTo(SearchResultReference[] values, int index) => InnerList.CopyTo(values, index);
67 |
68 | internal void Clear() => InnerList.Clear();
69 | }
70 |
71 | public class SearchResultEntry
72 | {
73 | private DirectoryControl[] _resultControls = null;
74 |
75 | internal SearchResultEntry(string dn) : this(dn, new SearchResultAttributeCollection()) {}
76 |
77 | internal SearchResultEntry(string dn, SearchResultAttributeCollection attrs)
78 | {
79 | DistinguishedName = dn;
80 | Attributes = attrs;
81 | }
82 |
83 | public string DistinguishedName { get; internal set; }
84 |
85 | public SearchResultAttributeCollection Attributes { get; }
86 |
87 | public DirectoryControl[] Controls
88 | {
89 | get
90 | {
91 | if (_resultControls == null)
92 | {
93 | return Array.Empty();
94 | }
95 |
96 | DirectoryControl[] controls = new DirectoryControl[_resultControls.Length];
97 | for (int i = 0; i < _resultControls.Length; i++)
98 | {
99 | controls[i] = new DirectoryControl(_resultControls[i].Type, _resultControls[i].GetValue(), _resultControls[i].IsCritical, _resultControls[i].ServerSide);
100 | }
101 | DirectoryControl.TransformControls(controls);
102 | return controls;
103 | }
104 | }
105 | }
106 |
107 | public class SearchResultEntryCollection : ReadOnlyCollectionBase
108 | {
109 | internal SearchResultEntryCollection() { }
110 |
111 | public SearchResultEntry this[int index] => (SearchResultEntry)InnerList[index];
112 |
113 | internal int Add(SearchResultEntry entry) => InnerList.Add(entry);
114 |
115 | public bool Contains(SearchResultEntry value) => InnerList.Contains(value);
116 |
117 | public int IndexOf(SearchResultEntry value) => InnerList.IndexOf(value);
118 |
119 | public void CopyTo(SearchResultEntry[] values, int index) => InnerList.CopyTo(values, index);
120 |
121 | internal void Clear() => InnerList.Clear();
122 | }
123 | }
124 |
--------------------------------------------------------------------------------
/src/System.DirectoryServices.Protocols/System/DirectoryServices/Protocols/common/SearchScope.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 | // See the LICENSE file in the project root for more information.
4 |
5 | namespace System.DirectoryServices.Protocols
6 | {
7 | public enum SearchScope
8 | {
9 | Base = 0,
10 | OneLevel = 1,
11 | Subtree = 2
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/System.DirectoryServices.Protocols/System/DirectoryServices/Protocols/common/encoding.Unix.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 |
3 | namespace System.DirectoryServices.Protocols
4 | {
5 | internal class Encoding
6 | {
7 | internal static Func PtrToString = PtrToStringUTF8;
8 | internal static Func StringToHGlobal = StringToHGlobalUTF8;
9 |
10 | private static IntPtr StringToHGlobalUTF8(string s, out int length)
11 | {
12 | if (s == null)
13 | {
14 | length = 0;
15 | return IntPtr.Zero;
16 | }
17 |
18 | var bytes = System.Text.Encoding.UTF8.GetBytes(s);
19 | var ptr = Marshal.AllocHGlobal(bytes.Length + 1);
20 | Marshal.Copy(bytes, 0, ptr, bytes.Length);
21 | Marshal.WriteByte(ptr, bytes.Length, 0);
22 | length = bytes.Length;
23 |
24 | return ptr;
25 | }
26 |
27 | private static IntPtr StringToHGlobalUTF8(string s)
28 | {
29 | int temp;
30 | return StringToHGlobalUTF8(s, out temp);
31 | }
32 |
33 | private static string PtrToStringUtf8(IntPtr ptr, int length)
34 | {
35 | if (ptr == IntPtr.Zero)
36 | return null;
37 |
38 | byte[] buff = new byte[length];
39 | Marshal.Copy(ptr, buff, 0, length);
40 | return System.Text.UTF8Encoding.UTF8.GetString(buff);
41 | }
42 |
43 | public static string PtrToStringUTF8(IntPtr ptr)
44 | {
45 | if (ptr == IntPtr.Zero)
46 | {
47 | return null;
48 | }
49 |
50 | int len = 0;
51 |
52 | while (Marshal.ReadByte(ptr, len) != 0)
53 | {
54 | ++len;
55 | }
56 |
57 | if (len == 0)
58 | {
59 | return string.Empty;
60 | }
61 |
62 | byte[] buffer = new byte[len];
63 | Marshal.Copy(ptr, buffer, 0, buffer.Length);
64 | return System.Text.Encoding.UTF8.GetString(buffer);
65 | }
66 |
67 |
68 |
69 | }
70 | }
--------------------------------------------------------------------------------
/src/System.DirectoryServices.Protocols/System/DirectoryServices/Protocols/common/encoding.Windows.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 |
3 | namespace System.DirectoryServices.Protocols
4 | {
5 | internal class Encoding
6 | {
7 | internal static Func PtrToString = Marshal.PtrToStringUni;
8 | internal static Func StringToHGlobal = Marshal.StringToHGlobalUni;
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/System.DirectoryServices.Protocols/System/DirectoryServices/Protocols/common/utils.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 | // See the LICENSE file in the project root for more information.
4 |
5 | using System.Runtime.InteropServices;
6 |
7 | namespace System.DirectoryServices.Protocols
8 | {
9 | internal class Utility
10 | {
11 | internal static bool IsLdapError(LdapError error)
12 | {
13 | if (error == LdapError.IsLeaf || error == LdapError.InvalidCredentials || error == LdapError.SendTimeOut)
14 | {
15 | return true;
16 | }
17 |
18 | return (error >= LdapError.ServerDown && error <= LdapError.ReferralLimitExceeded);
19 | }
20 |
21 | internal static bool IsResultCode(ResultCode code)
22 | {
23 | if (code >= ResultCode.Success && code <= ResultCode.SaslBindInProgress)
24 | {
25 | return true;
26 | }
27 |
28 | if (code >= ResultCode.NoSuchAttribute && code <= ResultCode.InvalidAttributeSyntax)
29 | {
30 | return true;
31 | }
32 |
33 | if (code >= ResultCode.NoSuchObject && code <= ResultCode.InvalidDNSyntax)
34 | {
35 | return true;
36 | }
37 |
38 | if (code >= ResultCode.InsufficientAccessRights && code <= ResultCode.LoopDetect)
39 | {
40 | return true;
41 | }
42 |
43 | if (code >= ResultCode.NamingViolation && code <= ResultCode.AffectsMultipleDsas)
44 | {
45 | return true;
46 | }
47 |
48 | return (code == ResultCode.AliasDereferencingProblem || code == ResultCode.InappropriateAuthentication || code == ResultCode.SortControlMissing || code == ResultCode.OffsetRangeError || code == ResultCode.VirtualListViewError || code == ResultCode.Other);
49 | }
50 |
51 | internal static IntPtr AllocHGlobalIntPtrArray(int size)
52 | {
53 | checked
54 | {
55 | IntPtr intPtrArray = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(IntPtr)) * size);
56 | for (int i = 0; i < size; i++)
57 | {
58 | IntPtr tempPtr = (IntPtr)((long)intPtrArray + Marshal.SizeOf(typeof(IntPtr)) * i);
59 | Marshal.WriteIntPtr(tempPtr, IntPtr.Zero);
60 | }
61 | return intPtrArray;
62 | }
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/src/System.DirectoryServices.Protocols/System/DirectoryServices/Protocols/ldap/LdapAsyncResult.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 | // See the LICENSE file in the project root for more information.
4 |
5 | using System.Threading;
6 | using Microsoft.Win32.SafeHandles;
7 |
8 | namespace System.DirectoryServices.Protocols
9 | {
10 | internal class LdapAsyncResult : IAsyncResult
11 | {
12 | private LdapAsyncWaitHandle _asyncWaitHandle = null;
13 | internal AsyncCallback _callback = null;
14 | internal bool _completed = false;
15 | private bool _completedSynchronously = false;
16 | internal ManualResetEvent _manualResetEvent = null;
17 | private object _stateObject = null;
18 | internal LdapRequestState _resultObject = null;
19 | internal bool _partialResults = false;
20 |
21 | public LdapAsyncResult(AsyncCallback callbackRoutine, object state, bool partialResults)
22 | {
23 | _stateObject = state;
24 | _callback = callbackRoutine;
25 | _manualResetEvent = new ManualResetEvent(false);
26 | _partialResults = partialResults;
27 | }
28 |
29 | object IAsyncResult.AsyncState => _stateObject;
30 |
31 | WaitHandle IAsyncResult.AsyncWaitHandle
32 | {
33 | get => _asyncWaitHandle ?? (_asyncWaitHandle = new LdapAsyncWaitHandle(_manualResetEvent.SafeWaitHandle));
34 | }
35 |
36 | bool IAsyncResult.CompletedSynchronously => _completedSynchronously;
37 |
38 | bool IAsyncResult.IsCompleted => _completed;
39 |
40 | public override int GetHashCode() => _manualResetEvent.GetHashCode();
41 |
42 | public override bool Equals(object obj)
43 | {
44 | if (!(obj is LdapAsyncResult otherAsyncResult))
45 | {
46 | return false;
47 | }
48 |
49 | return this == otherAsyncResult;
50 | }
51 |
52 | private sealed class LdapAsyncWaitHandle : WaitHandle
53 | {
54 | public LdapAsyncWaitHandle(SafeWaitHandle handle) : base()
55 | {
56 | SafeWaitHandle = handle;
57 | }
58 |
59 | ~LdapAsyncWaitHandle() => SafeWaitHandle = null;
60 | }
61 | }
62 |
63 | internal class LdapRequestState
64 | {
65 | internal DirectoryResponse _response = null;
66 | internal LdapAsyncResult _ldapAsync = null;
67 | internal Exception _exception = null;
68 | internal bool _abortCalled = false;
69 |
70 | public LdapRequestState() { }
71 | }
72 |
73 | internal enum ResultsStatus
74 | {
75 | PartialResult = 0,
76 | CompleteResult = 1,
77 | Done = 2
78 | }
79 |
80 | internal class LdapPartialAsyncResult : LdapAsyncResult
81 | {
82 | internal LdapConnection _con;
83 | internal int _messageID = -1;
84 | internal bool _partialCallback;
85 | internal ResultsStatus _resultStatus = ResultsStatus.PartialResult;
86 | internal TimeSpan _requestTimeout;
87 |
88 | internal SearchResponse _response = null;
89 | internal Exception _exception = null;
90 | internal DateTime _startTime;
91 |
92 | public LdapPartialAsyncResult(int messageID, AsyncCallback callbackRoutine, object state, bool partialResults, LdapConnection con, bool partialCallback, TimeSpan requestTimeout) : base(callbackRoutine, state, partialResults)
93 | {
94 | _messageID = messageID;
95 | _con = con;
96 | _partialResults = true;
97 | _partialCallback = partialCallback;
98 | _requestTimeout = requestTimeout;
99 | _startTime = DateTime.Now;
100 | }
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/src/System.DirectoryServices.Protocols/System/DirectoryServices/Protocols/ldap/LdapDirectoryIdentifier.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 | // See the LICENSE file in the project root for more information.
4 |
5 | namespace System.DirectoryServices.Protocols
6 | {
7 | public class LdapDirectoryIdentifier : DirectoryIdentifier
8 | {
9 | private string[] _servers = null;
10 |
11 | public LdapDirectoryIdentifier(string server) : this(server != null ? new string[] { server } : null, false, false)
12 | {
13 | }
14 |
15 | public LdapDirectoryIdentifier(string server, int portNumber) : this(server != null ? new string[] { server } : null, portNumber, false, false)
16 | {
17 | }
18 |
19 | public LdapDirectoryIdentifier(string server, bool fullyQualifiedDnsHostName, bool connectionless) : this(server != null ? new string[] { server } : null, fullyQualifiedDnsHostName, connectionless)
20 | {
21 | }
22 |
23 | public LdapDirectoryIdentifier(string server, int portNumber, bool fullyQualifiedDnsHostName, bool connectionless) : this(server != null ? new string[] { server } : null, portNumber, fullyQualifiedDnsHostName, connectionless)
24 | {
25 | }
26 |
27 | public LdapDirectoryIdentifier(string[] servers, bool fullyQualifiedDnsHostName, bool connectionless)
28 | {
29 | // validate the servers, we don't allow space in the server name
30 | if (servers != null)
31 | {
32 | _servers = new string[servers.Length];
33 | for (int i = 0; i < servers.Length; i++)
34 | {
35 | if (servers[i] != null)
36 | {
37 | string trimmedName = servers[i].Trim();
38 | string[] result = trimmedName.Split(new char[] { ' ' });
39 | if (result.Length > 1)
40 | {
41 | throw new ArgumentException(SR.WhiteSpaceServerName);
42 | }
43 |
44 | _servers[i] = trimmedName;
45 | }
46 | }
47 | }
48 |
49 | FullyQualifiedDnsHostName = fullyQualifiedDnsHostName;
50 | Connectionless = connectionless;
51 | }
52 |
53 | public LdapDirectoryIdentifier(string[] servers, int portNumber, bool fullyQualifiedDnsHostName, bool connectionless) : this(servers, fullyQualifiedDnsHostName, connectionless)
54 | {
55 | PortNumber = portNumber;
56 | }
57 |
58 | public string[] Servers
59 | {
60 | get
61 | {
62 | if (_servers == null)
63 | {
64 | return Array.Empty();
65 | }
66 |
67 | var temporaryServers = new string[_servers.Length];
68 | for (int i = 0; i < _servers.Length; i++)
69 | {
70 | if (_servers[i] != null)
71 | {
72 | temporaryServers[i] = string.Copy(_servers[i]);
73 | }
74 | else
75 | {
76 | temporaryServers[i] = null;
77 | }
78 | }
79 |
80 | return temporaryServers;
81 | }
82 | }
83 |
84 | public bool Connectionless { get; }
85 |
86 | public bool FullyQualifiedDnsHostName { get; }
87 |
88 | public int PortNumber { get; } = 389;
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/src/System.DirectoryServices.Protocols/System/DirectoryServices/Protocols/ldap/LdapException.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 | // See the LICENSE file in the project root for more information.
4 |
5 | using System.Collections.Generic;
6 | using System.Runtime.Serialization;
7 |
8 | namespace System.DirectoryServices.Protocols
9 | {
10 | internal enum LdapError
11 | {
12 | IsLeaf = 0x23,
13 | InvalidCredentials = 49,
14 | ServerDown = 0x51,
15 | LocalError = 0x52,
16 | EncodingError = 0x53,
17 | DecodingError = 0x54,
18 | TimeOut = 0x55,
19 | AuthUnknown = 0x56,
20 | FilterError = 0x57,
21 | UserCancelled = 0x58,
22 | ParameterError = 0x59,
23 | NoMemory = 0x5a,
24 | ConnectError = 0x5b,
25 | NotSupported = 0x5c,
26 | NoResultsReturned = 0x5e,
27 | ControlNotFound = 0x5d,
28 | MoreResults = 0x5f,
29 | ClientLoop = 0x60,
30 | ReferralLimitExceeded = 0x61,
31 | SendTimeOut = 0x70
32 | }
33 |
34 | internal class LdapErrorMappings
35 | {
36 | private static readonly Dictionary s_resultCodeMapping = new Dictionary(capacity: 20)
37 | {
38 | { LdapError.IsLeaf, SR.LDAP_IS_LEAF },
39 | { LdapError.InvalidCredentials, SR.LDAP_INVALID_CREDENTIALS },
40 | { LdapError.ServerDown, SR.LDAP_SERVER_DOWN },
41 | { LdapError.LocalError, SR.LDAP_LOCAL_ERROR },
42 | { LdapError.EncodingError, SR.LDAP_ENCODING_ERROR },
43 | { LdapError.DecodingError, SR.LDAP_DECODING_ERROR },
44 | { LdapError.TimeOut, SR.LDAP_TIMEOUT },
45 | { LdapError.AuthUnknown, SR.LDAP_AUTH_UNKNOWN },
46 | { LdapError.FilterError, SR.LDAP_FILTER_ERROR },
47 | { LdapError.UserCancelled, SR.LDAP_USER_CANCELLED },
48 | { LdapError.ParameterError, SR.LDAP_PARAM_ERROR },
49 | { LdapError.NoMemory, SR.LDAP_NO_MEMORY },
50 | { LdapError.ConnectError, SR.LDAP_CONNECT_ERROR },
51 | { LdapError.NotSupported, SR.LDAP_NOT_SUPPORTED },
52 | { LdapError.NoResultsReturned, SR.LDAP_NO_RESULTS_RETURNED },
53 | { LdapError.ControlNotFound, SR.LDAP_CONTROL_NOT_FOUND },
54 | { LdapError.MoreResults, SR.LDAP_MORE_RESULTS_TO_RETURN },
55 | { LdapError.ClientLoop, SR.LDAP_CLIENT_LOOP },
56 | { LdapError.ReferralLimitExceeded, SR.LDAP_REFERRAL_LIMIT_EXCEEDED },
57 | { LdapError.SendTimeOut, SR.LDAP_SEND_TIMEOUT }
58 | };
59 |
60 | public static string MapResultCode(int errorCode)
61 | {
62 | s_resultCodeMapping.TryGetValue((LdapError)errorCode, out string errorMessage);
63 | return errorMessage;
64 | }
65 | }
66 |
67 | [Serializable]
68 | [System.Runtime.CompilerServices.TypeForwardedFrom("System.DirectoryServices.Protocols, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
69 | public class LdapException : DirectoryException, ISerializable
70 | {
71 | protected LdapException(SerializationInfo info, StreamingContext context) : base(info, context) { }
72 |
73 | public LdapException() : base() { }
74 |
75 | public LdapException(string message) : base(message) { }
76 |
77 | public LdapException(string message, Exception inner) : base(message, inner) { }
78 |
79 | public LdapException(int errorCode) : base(SR.DefaultLdapError)
80 | {
81 | ErrorCode = errorCode;
82 | }
83 |
84 | public LdapException(int errorCode, string message) : base(message)
85 | {
86 | ErrorCode = errorCode;
87 | }
88 |
89 | public LdapException(int errorCode, string message, string serverErrorMessage) : base(message)
90 | {
91 | ErrorCode = errorCode;
92 | ServerErrorMessage = serverErrorMessage;
93 | }
94 |
95 | public LdapException(int errorCode, string message, Exception inner) : base(message, inner)
96 | {
97 | ErrorCode = errorCode;
98 | }
99 |
100 | public int ErrorCode { get; }
101 |
102 | public string ServerErrorMessage { get; }
103 |
104 | public PartialResultsCollection PartialResults { get; } = new PartialResultsCollection();
105 | }
106 |
107 | [Serializable]
108 | [System.Runtime.CompilerServices.TypeForwardedFrom("System.DirectoryServices.Protocols, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
109 | public class TlsOperationException : DirectoryOperationException
110 | {
111 | protected TlsOperationException(SerializationInfo info, StreamingContext context) : base(info, context) { }
112 |
113 | public TlsOperationException() : base() { }
114 |
115 | public TlsOperationException(string message) : base(message) { }
116 |
117 | public TlsOperationException(string message, Exception inner) : base(message, inner) { }
118 |
119 | public TlsOperationException(DirectoryResponse response) : base(response)
120 | {
121 | }
122 |
123 | public TlsOperationException(DirectoryResponse response, string message) : base(response, message)
124 | {
125 | }
126 |
127 | public TlsOperationException(DirectoryResponse response, string message, Exception inner) : base(response, message, inner)
128 | {
129 | }
130 | }
131 |
132 | internal class ErrorChecking
133 | {
134 | public static void CheckAndSetLdapError(int error)
135 | {
136 | if (error != (int)ResultCode.Success)
137 | {
138 | if (Utility.IsResultCode((ResultCode)error))
139 | {
140 | string errorMessage = OperationErrorMappings.MapResultCode(error);
141 | throw new DirectoryOperationException(null, errorMessage);
142 | }
143 | else if (Utility.IsLdapError((LdapError)error))
144 | {
145 | string errorMessage = LdapErrorMappings.MapResultCode(error);
146 | throw new LdapException(error, errorMessage);
147 | }
148 | else
149 | {
150 | throw new LdapException(error);
151 | }
152 | }
153 | }
154 | }
155 | }
156 |
--------------------------------------------------------------------------------
/src/System.DirectoryServices.Protocols/System/DirectoryServices/Protocols/ldap/SafeHandles.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 | // See the LICENSE file in the project root for more information.
4 |
5 | using Microsoft.Win32.SafeHandles;
6 | using System.Runtime.InteropServices;
7 | using System.Security;
8 |
9 | namespace System.DirectoryServices.Protocols
10 | {
11 | internal sealed class BerSafeHandle : SafeHandleZeroOrMinusOneIsInvalid
12 | {
13 | internal BerSafeHandle() : base(true)
14 | {
15 | SetHandle(Wldap32.ber_alloc(1));
16 | if (handle == IntPtr.Zero)
17 | {
18 | throw new OutOfMemoryException();
19 | }
20 | }
21 |
22 | internal BerSafeHandle(berval value) : base(true)
23 | {
24 | SetHandle(Wldap32.ber_init(value));
25 | if (handle == IntPtr.Zero)
26 | {
27 | throw new BerConversionException();
28 | }
29 | }
30 |
31 | override protected bool ReleaseHandle()
32 | {
33 | Wldap32.ber_free(handle, 1);
34 | return true;
35 | }
36 | }
37 |
38 | internal sealed class HGlobalMemHandle : SafeHandleZeroOrMinusOneIsInvalid
39 | {
40 | internal HGlobalMemHandle(IntPtr value) : base(true)
41 | {
42 | SetHandle(value);
43 | }
44 |
45 | override protected bool ReleaseHandle()
46 | {
47 | Marshal.FreeHGlobal(handle);
48 | return true;
49 | }
50 | }
51 |
52 | internal sealed class ConnectionHandle : SafeHandleZeroOrMinusOneIsInvalid
53 | {
54 | internal bool _needDispose = false;
55 |
56 | internal ConnectionHandle() : base(true)
57 | {
58 | SetHandle(Wldap32.ldap_init(null, 389));
59 |
60 | if (handle == IntPtr.Zero)
61 | {
62 | int error = Wldap32.LdapGetLastError();
63 | if (Utility.IsLdapError((LdapError)error))
64 | {
65 | string errorMessage = LdapErrorMappings.MapResultCode(error);
66 | throw new LdapException(error, errorMessage);
67 | }
68 | else
69 | {
70 | throw new LdapException(error);
71 | }
72 | }
73 | }
74 |
75 | internal ConnectionHandle(IntPtr value, bool disposeHandle) : base(true)
76 | {
77 | _needDispose = disposeHandle;
78 | if (value == IntPtr.Zero)
79 | {
80 | int error = Wldap32.LdapGetLastError();
81 | if (Utility.IsLdapError((LdapError)error))
82 | {
83 | string errorMessage = LdapErrorMappings.MapResultCode(error);
84 | throw new LdapException(error, errorMessage);
85 | }
86 | else
87 | {
88 | throw new LdapException(error);
89 | }
90 | }
91 | else
92 | {
93 | SetHandle(value);
94 | }
95 | }
96 | override protected bool ReleaseHandle()
97 | {
98 | if (handle != IntPtr.Zero)
99 | {
100 | if (_needDispose)
101 | {
102 | Wldap32.ldap_unbind(handle);
103 | }
104 |
105 | handle = IntPtr.Zero;
106 | }
107 | return true;
108 | }
109 | }
110 | }
111 |
--------------------------------------------------------------------------------
/tests/AddRequestTests.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 | // See the LICENSE file in the project root for more information.
4 |
5 | using System.Collections.Generic;
6 | using System.Linq;
7 | using Xunit;
8 |
9 | namespace System.DirectoryServices.Protocols.Tests
10 | {
11 | public class AddRequestTests
12 | {
13 | [Fact]
14 | public void Ctor_Default()
15 | {
16 | var request = new AddRequest();
17 | Assert.Empty(request.Attributes);
18 | Assert.Empty(request.Controls);
19 | Assert.Null(request.DistinguishedName);
20 | Assert.Null(request.RequestId);
21 | }
22 |
23 | public static IEnumerable