Skip to content

Commit

Permalink
v5.5.3.1309
Browse files Browse the repository at this point in the history
* _New feature_ - added support for $Schema parameter. Gets passed to Import and Export script
* Optimized tracing and fixed minor bugs in tracing for errors and warnings
  • Loading branch information
sorengranfeldt committed Sep 13, 2018
1 parent d14bac9 commit 4c9e251
Show file tree
Hide file tree
Showing 10 changed files with 582 additions and 625 deletions.
19 changes: 8 additions & 11 deletions Granfeldt.PowerShell.ManagementAgent/MA.Export.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using Microsoft.MetadirectoryServices;
// july 5, 2018, soren granfeldt
// - added schema psobject as parameter to export script

using Microsoft.MetadirectoryServices;
using System;
using System.Collections;
using System.Collections.Generic;
Expand Down Expand Up @@ -30,17 +33,15 @@ int IMAExtensible2CallExport.ExportMaxPageSize
}
void IMAExtensible2CallExport.OpenExportConnection(System.Collections.ObjectModel.KeyedCollection<string, ConfigParameter> configParameters, Schema types, OpenExportConnectionRunStep exportRunStep)
{
Tracer.IndentLevel = 0;
Tracer.Enter("openexportconnection");
Tracer.Indent();
try
{
InitializeConfigParameters(configParameters);

OpenRunspace();
schema = types;
InitializeSchemaVariables(types);

exportType = exportRunStep.ExportType;
exportType = exportRunStep.ExportType;
Tracer.TraceInformation("export-type '{0}'", exportType);
exportBatchSize = exportRunStep.BatchSize;
Tracer.TraceInformation("export-batch-size '{0}'", exportBatchSize);
Expand All @@ -52,14 +53,12 @@ void IMAExtensible2CallExport.OpenExportConnection(System.Collections.ObjectMode
}
finally
{
Tracer.Unindent();
Tracer.Exit("openexportconnection");
}
}
PutExportEntriesResults IMAExtensible2CallExport.PutExportEntries(IList<CSEntryChange> csentries)
{
Tracer.Enter("putexportentries");
Tracer.Indent();
PutExportEntriesResults exportEntries = new PutExportEntriesResults();
PSDataCollection<PSObject> exportPipeline = new PSDataCollection<PSObject>();
try
Expand All @@ -69,8 +68,9 @@ PutExportEntriesResults IMAExtensible2CallExport.PutExportEntries(IList<CSEntryC
cmd.Parameters.Add(new CommandParameter("Password", Password));
cmd.Parameters.Add(new CommandParameter("Credentials", GetSecureCredentials()));
cmd.Parameters.Add(new CommandParameter("ExportType", exportType));
cmd.Parameters.Add(new CommandParameter("Schema", schemaPSObject));

foreach (CSEntryChange csentryChange in csentries)
foreach (CSEntryChange csentryChange in csentries)
{
Tracer.TraceInformation("adding-object id: {0}, dn: '{1}' [{2}]", csentryChange.Identifier, csentryChange.DN, csentryChange.ObjectModificationType);
if (ExportSimpleObjects)
Expand Down Expand Up @@ -196,14 +196,12 @@ PutExportEntriesResults IMAExtensible2CallExport.PutExportEntries(IList<CSEntryC
}
finally
{
Tracer.Unindent();
Tracer.Exit("putexportentries");
}
}
void IMAExtensible2CallExport.CloseExportConnection(CloseExportConnectionRunStep exportRunStep)
{
Tracer.Enter("closeexportconnection");
Tracer.Indent();
try
{
CloseRunspace();
Expand All @@ -216,7 +214,6 @@ void IMAExtensible2CallExport.CloseExportConnection(CloseExportConnectionRunStep
}
finally
{
Tracer.Unindent();
Tracer.Exit("closeexportconnection");
}
}
Expand Down
23 changes: 0 additions & 23 deletions Granfeldt.PowerShell.ManagementAgent/MA.Impersonation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ void SetupImpersonationToken()
}
finally
{
Tracer.Unindent();
Tracer.Exit("setupimpersonationtoken");
}
}
Expand All @@ -186,7 +185,6 @@ void RevertImpersonation()
}

Tracer.Enter("revertimpersonation");
Tracer.Indent();
try
{
Tracer.TraceInformation("closing-impersonation-context");
Expand All @@ -204,31 +202,10 @@ void RevertImpersonation()
}
finally
{
Tracer.Unindent();
Tracer.Exit("revertimpersonation");
}
}

//IntPtr SetupImpersonationTokenOld()
//{
// Tracer.Enter("setupimpersonationtoken");
// IntPtr token = IntPtr.Zero;

// bool success = NativeMethods.LogonUser(impersonationUsername, impersonationUserDomain, impersonationUserPassword, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, out token);
// if (!success)
// {
// SecurityException ex = new SecurityException(string.Format("failed-to-impersonate: domain: '{0}', username: '{1}', password: **secret***", impersonationUserDomain, impersonationUsername));
// Tracer.TraceError(ex.ToString());
// throw ex;
// }
// else
// {
// Tracer.TraceInformation("succeeded-in-impersonating: domain: '{0}', username: '{1}', password: **secret***", impersonationUserDomain, impersonationUsername);
// }

// Tracer.Exit("setupimpersonationtoken");
// return token;
//}
}

}
Loading

0 comments on commit 4c9e251

Please sign in to comment.