Appendix D: MVExtension Source Code
using System;
using Microsoft.MetadirectoryServices;
namespace Mms_Metaverse
{
/// <summary>
/// Summary description for MVExtensionObject.
/// </summary>
public class MVExtensionObject : IMVSynchronization
{
public MVExtensionObject()
{
//
// TODO: Add constructor logic here
//
}
void IMVSynchronization.Initialize ()
{
//
// TODO: Add initialization logic here
//
}
void IMVSynchronization.Terminate ()
{
//
// TODO: Add termination logic here
//
}
void IMVSynchronization.Provision (MVEntry mventry)
{
ConnectedMA ManagementAgent;
int Connectors = 0;
CSEntry csentry;
ReferenceValue DN;
ManagementAgent = mventry.ConnectedMAs["SQL_ECMA2"];
Connectors = ManagementAgent.Connectors.Count;
//Provision to SQL
if (0 == Connectors)
{
csentry = ManagementAgent.Connectors.StartNewConnector("Person");
csentry["EmployeeID"].Value = mventry["employeeID"].Value;
csentry["AccountName"].Value = mventry["accountName"].Value;
csentry["EMail"].Value = mventry["mail"].Value;
csentry["FirstName"].Value = mventry["givenName"].Value;
csentry["LastName"].Value = mventry["sn"].Value;
csentry["FullName"].Value = mventry["displayName"].Value;
csentry.CommitNewConnector();
}
if (1 == Connectors)
{
}
ManagementAgent = mventry.ConnectedMAs["AD_ECMA2"];
Connectors = ManagementAgent.Connectors.Count;
//Provision to AD
if (0 == Connectors)
{
DN = ManagementAgent.EscapeDNComponent("CN=" + mventry["displayName"].Value).Concat("OU=ECMA2,DC=corp,DC=contoso,DC=com");
csentry = ManagementAgent.Connectors.StartNewConnector("user");
csentry.DN = DN;
csentry["samAccountName"].Value = mventry["accountName"].Value;
csentry["employeeID"].Value = mventry["employeeID"].Value;
csentry.CommitNewConnector();
}
if (1 == Connectors)
{
}
}
bool IMVSynchronization.ShouldDeleteFromMV (CSEntry csentry, MVEntry mventry)
{
//
// TODO: Add MV deletion logic here
//
throw new EntryPointNotImplementedException();
}
}
}