Convert EmployeeEndDate to AcountExpires by adding 1 year
Hello! Here is the example to add 180 days from user's date provisoning by converting from emploeeenddate to accountexpires. We need to add number of the days (for example 365) to the employyenddate date value. To set accountExpires to expire after 180 days from user´s date provisioning csentry["accountExpires"].Value = DateTime.Now.AddDays(180).ToFileTimeUtc().ToString(); How to add the number of the days to employeeenddate or accountexpiresdate? csentry["accountExpires"].Value = DateTime.Now.AddDays(180).ToFileTimeUtc().ToString(); Thanks
October 3rd, 2011 3:57am

Hi you can use the following code as part of the "MapAttributesForExport(ByVal FlowRuleName" and also add the "Private Function ConvertToFileTimeUtc": *********************** Public Sub MapAttributesForExport(ByVal FlowRuleName As String, ByVal mventry As MVEntry, ByVal csentry As CSEntry) Implements IMASynchronization.MapAttributesForExport Select Case FlowRuleName Case "cd.user:accountExpires<-mv.person:employeeEndDate" If Not mventry("employeeEndDate").IsPresent Then csentry("accountExpires").IntegerValue = 0 Else If mventry("employeeEndDate").IsPresent Then Dim endDateSTR As String = mventry("employeeEndDate").Value Dim endDate As DateTime = DateTime.Parse(endDateSTR) Dim NewendDate As DateTime = endDate.AddDays(1) Dim NewendDateSTR As String = NewendDate.ToString csentry("accountExpires").IntegerValue = ConvertToFileTimeUtc(NewendDateSTR) End If End If Case Else Throw New EntryPointNotImplementedException() End Select End Sub Private Function ConvertToFileTimeUtc(ByVal sourceval As String) As Long Return DateTime .Parse(sourceval).ToFileTimeUtc() End Function ****************************** Regards, Andre
Free Windows Admin Tool Kit Click here and download it now
October 3rd, 2011 5:19am

Thanks, about the code I copied the code in to extension project. When I tryed build the externsion, the following error is generrated: Error 1 Name 'ConvertToFileTimeUtc' is not declared. I see that there is no function 'ConvertToFileTimeUtc' . Do I need to ise ToFileTimeUtc? How to solve the problem? Thanks!
October 3rd, 2011 8:18am

Thanks, about the code I copied the code in to extension project. When I tryed build the externsion, the following error is generrated: Error 1 Name 'ConvertToFileTimeUtc' is not declared. I see that there is no function 'ConvertToFileTimeUtc' . Do I need to ise ToFileTimeUtc? How to solve the problem? Thanks!
Free Windows Admin Tool Kit Click here and download it now
October 3rd, 2011 8:18am

Sorry I din't mentioned eralier that the private function must be at the end of the code prior to "End Class" as below. Public Sub MapAttributesForExport(ByVal FlowRuleName As String, ByVal mventry As MVEntry, ByVal csentry As CSEntry) Implements IMASynchronization.MapAttributesForExport Select Case FlowRuleName Case "cd.user:accountExpires<-mv.person:employeeEndDate" If Not mventry("employeeEndDate").IsPresent Then csentry( "accountExpires" ).IntegerValue = 0 Else If mventry("employeeEndDate").IsPresent Then Dim endDateSTR As String = mventry("employeeEndDate" ).Value Dim endDate As DateTime = DateTime .Parse(endDateSTR) Dim NewendDate As DateTime = endDate.AddDays(1) Dim NewendDateSTR As String = NewendDate.ToString csentry( "accountExpires" ).IntegerValue = ConvertToFileTimeUtc(NewendDateSTR) End If End If Case Else Throw New EntryPointNotImplementedException() End Select End Sub Public Function Deprovision(ByVal csentry As CSEntry) As DeprovisionAction Implements IMASynchronization.Deprovision Throw New EntryPointNotImplementedException() End Function Private Function ConvertToFileTimeUtc(ByVal sourceval As String) As Long Return DateTime .Parse(sourceval).ToFileTimeUtc() End Function End Class
October 3rd, 2011 9:17am

Sorry I din't mentioned eralier that the private function must be at the end of the code prior to "End Class" as below. Public Sub MapAttributesForExport(ByVal FlowRuleName As String, ByVal mventry As MVEntry, ByVal csentry As CSEntry) Implements IMASynchronization.MapAttributesForExport Select Case FlowRuleName Case "cd.user:accountExpires<-mv.person:employeeEndDate" If Not mventry("employeeEndDate").IsPresent Then csentry( "accountExpires" ).IntegerValue = 0 Else If mventry("employeeEndDate").IsPresent Then Dim endDateSTR As String = mventry("employeeEndDate" ).Value Dim endDate As DateTime = DateTime .Parse(endDateSTR) Dim NewendDate As DateTime = endDate.AddDays(1) Dim NewendDateSTR As String = NewendDate.ToString csentry( "accountExpires" ).IntegerValue = ConvertToFileTimeUtc(NewendDateSTR) End If End If Case Else Throw New EntryPointNotImplementedException() End Select End Sub Public Function Deprovision(ByVal csentry As CSEntry) As DeprovisionAction Implements IMASynchronization.Deprovision Throw New EntryPointNotImplementedException() End Function Private Function ConvertToFileTimeUtc(ByVal sourceval As String) As Long Return DateTime .Parse(sourceval).ToFileTimeUtc() End Function End Class
Free Windows Admin Tool Kit Click here and download it now
October 3rd, 2011 9:17am

Anyway, the same error. Error 1 Name 'ConvertToFileTimeUtc' is not declared. I copied the following code: Public Sub MapAttributesForExport(ByVal FlowRuleName As String, ByVal mventry As MVEntry, ByVal csentry As CSEntry) Implements IMASynchronization.MapAttributesForExport ' TODO: Add export attribute flow code here Select Case FlowRuleName Case "cd.user:accountExpires<-mv.person:employeeEndDate" If Not mventry("employeeEndDate").IsPresent Then csentry("accountExpires").IntegerValue = 0 Else If mventry("employeeEndDate").IsPresent Then Dim endDateSTR As String = mventry("employeeEndDate").Value Dim endDate As DateTime = DateTime.Parse(endDateSTR) Dim NewendDate As DateTime = endDate.AddDays(1) Dim NewendDateSTR As String = NewendDate.ToString csentry("accountExpires").IntegerValue = ConvertToFileTimeUtc(NewendDateSTR) End If End If Case Else Throw New EntryPointNotImplementedException() End Select End Sub Please help to solve the error!
October 3rd, 2011 9:57am

Hi, Did you add the private Function: Private Function ConvertToFileTimeUtc(ByVal sourceval As String) As Long Return DateTime.Parse(sourceval).ToFileTimeUtc() End Function
Free Windows Admin Tool Kit Click here and download it now
October 3rd, 2011 10:09am

Thanks, the build is working now, but I see that the expression does not add the date. How to solve the problem? Thanks!
October 3rd, 2011 10:22am

Hi, Did you add a synch rule for employee end date to be converted to accountexpiry. I see I have pasted the "AddDays" and not the "AddYears" Dim NewendDate As DateTime = endDate.AddDays(1) must change to: Dim NewendDate As DateTime = endDate.AddYears(1) In your AD MA open the the Attribute flows and select the following: Connector Space(Active Directory) attribute for the user: accountExpires Export from the Metaverse person:employeeEndDate by Rules Extension. This will create the following Flow Rule Name: cd.user:accountExpires<-mv.person:employeeEndDate If you run a synchronization preview on a specific user you will see that the value will change for the accountExpires attribute in AD. If I understand know you want to convert the accountExpires from AD to employeeEndDate in the MV? Regards Andre
Free Windows Admin Tool Kit Click here and download it now
October 3rd, 2011 11:20am

Hi, Did you add a synch rule for employee end date to be converted to accountexpiry. I see I have pasted the "AddDays" and not the "AddYears" Dim NewendDate As DateTime = endDate.AddDays(1) must change to: Dim NewendDate As DateTime = endDate.AddYears(1) In your AD MA open the the Attribute flows and select the following: Connector Space(Active Directory) attribute for the user: accountExpires Export from the Metaverse person:employeeEndDate by Rules Extension. This will create the following Flow Rule Name: cd.user:accountExpires<-mv.person:employeeEndDate If you run a synchronization preview on a specific user you will see that the value will change for the accountExpires attribute in AD. If I understand know you want to convert the accountExpires from AD to employeeEndDate in the MV? Regards Andre
October 3rd, 2011 11:20am

If I understand know you want to convert the accountExpires from AD to employeeEndDate in the MV? I want to convert the mployeeEndDate (MV) to the accountExpires (AD) and add years / days to this date. I must change the code? Did you add a synch rule for employee end date to be converted to accountexpiry Did I must create the sync rule if I create the advanced flow attribute flow in the ADMA?
Free Windows Admin Tool Kit Click here and download it now
October 3rd, 2011 12:24pm

If I understand know you want to convert the accountExpires from AD to employeeEndDate in the MV? I want to convert the mployeeEndDate (MV) to the accountExpires (AD) and add years / days to this date. I must change the code? Did you add a synch rule for employee end date to be converted to accountexpiry Did I must create the sync rule if I create the advanced flow attribute flow in the ADMA?
October 3rd, 2011 12:24pm

If I understand know you want to convert the accountExpires from AD to employeeEndDate in the MV? I want to convert the mployeeEndDate (MV) to the accountExpires (AD) and add years / days to this date. I must change the code? Did you add a synch rule for employee end date to be converted to accountexpiry Did I must create the sync rule if I create the advanced flow attribute flow in the ADMA? 1. The code sample provided does this although it adds 1 day rather than 1 year so you would want to tweak that. 2. No.My Book - Active Directory, 4th Edition My Blog - www.briandesmond.com
Free Windows Admin Tool Kit Click here and download it now
October 3rd, 2011 12:32pm

If I understand know you want to convert the accountExpires from AD to employeeEndDate in the MV? I want to convert the mployeeEndDate (MV) to the accountExpires (AD) and add years / days to this date. I must change the code? Did you add a synch rule for employee end date to be converted to accountexpiry Did I must create the sync rule if I create the advanced flow attribute flow in the ADMA? 1. The code sample provided does this although it adds 1 day rather than 1 year so you would want to tweak that. 2. No.My Book - Active Directory, 4th Edition My Blog - www.briandesmond.com
October 3rd, 2011 12:32pm

Edit: It works now. I ned to create the delta import in ADMA. Thanks! The final code: Imports Microsoft.MetadirectoryServices Public Class MAExtensionObject Implements IMASynchronization Public Sub Initialize() Implements IMASynchronization.Initialize ' TODO: Add initialization code here End Sub Public Sub Terminate() Implements IMASynchronization.Terminate ' TODO: Add termination code here End Sub Public Function ShouldProjectToMV(ByVal csentry As CSEntry, ByRef MVObjectType As String) As Boolean Implements IMASynchronization.ShouldProjectToMV ' TODO: Remove this throw statement if you implement this method Throw New EntryPointNotImplementedException() End Function Public Function FilterForDisconnection(ByVal csentry As CSEntry) As Boolean Implements IMASynchronization.FilterForDisconnection ' TODO: Add connector filter code here Throw New EntryPointNotImplementedException() End Function Public Sub MapAttributesForJoin(ByVal FlowRuleName As String, ByVal csentry As CSEntry, ByRef values As ValueCollection) Implements IMASynchronization.MapAttributesForJoin ' TODO: Add join mapping code here Throw New EntryPointNotImplementedException() End Sub Public Function ResolveJoinSearch(ByVal joinCriteriaName As String, ByVal csentry As CSEntry, ByVal rgmventry() As MVEntry, ByRef imventry As Integer, ByRef MVObjectType As String) As Boolean Implements IMASynchronization.ResolveJoinSearch ' TODO: Add join resolution code here Throw New EntryPointNotImplementedException() End Function Public Sub MapAttributesForImport(ByVal FlowRuleName As String, ByVal csentry As CSEntry, ByVal mventry As MVEntry) Implements IMASynchronization.MapAttributesForImport ' TODO: write your import attribute flow code Throw New EntryPointNotImplementedException() End Sub Public Sub MapAttributesForExport(ByVal FlowRuleName As String, ByVal mventry As MVEntry, ByVal csentry As CSEntry) Implements IMASynchronization.MapAttributesForExport ' TODO: Add export attribute flow code here Select Case FlowRuleName Case "cd.user:accountExpires<-mv.person:employeeEndDate" If Not mventry("employeeEndDate").IsPresent Then csentry("accountExpires").IntegerValue = 0 Else If mventry("employeeEndDate").IsPresent Then Dim endDateSTR As String = mventry("employeeEndDate").Value Dim endDate As DateTime = DateTime.Parse(endDateSTR) Dim NewendDate As DateTime = endDate.AddYears(1) Dim NewendDateSTR As String = NewendDate.ToString csentry("accountExpires").IntegerValue = ConvertToFileTimeUtc(NewendDateSTR) End If End If Case Else Throw New EntryPointNotImplementedException() End Select End Sub Public Function Deprovision(ByVal csentry As CSEntry) As DeprovisionAction Implements IMASynchronization.Deprovision ' TODO: Remove this throw statement if you implement this method Throw New EntryPointNotImplementedException() End Function Private Function ConvertToFileTimeUtc(ByVal sourceval As String) As Long Return DateTime.Parse(sourceval).ToFileTimeUtc() End Function End Class
Free Windows Admin Tool Kit Click here and download it now
October 4th, 2011 3:04am

Edit: It works now. I ned to create the delta import in ADMA. Thanks! The final code: Imports Microsoft.MetadirectoryServices Public Class MAExtensionObject Implements IMASynchronization Public Sub Initialize() Implements IMASynchronization.Initialize ' TODO: Add initialization code here End Sub Public Sub Terminate() Implements IMASynchronization.Terminate ' TODO: Add termination code here End Sub Public Function ShouldProjectToMV(ByVal csentry As CSEntry, ByRef MVObjectType As String) As Boolean Implements IMASynchronization.ShouldProjectToMV ' TODO: Remove this throw statement if you implement this method Throw New EntryPointNotImplementedException() End Function Public Function FilterForDisconnection(ByVal csentry As CSEntry) As Boolean Implements IMASynchronization.FilterForDisconnection ' TODO: Add connector filter code here Throw New EntryPointNotImplementedException() End Function Public Sub MapAttributesForJoin(ByVal FlowRuleName As String, ByVal csentry As CSEntry, ByRef values As ValueCollection) Implements IMASynchronization.MapAttributesForJoin ' TODO: Add join mapping code here Throw New EntryPointNotImplementedException() End Sub Public Function ResolveJoinSearch(ByVal joinCriteriaName As String, ByVal csentry As CSEntry, ByVal rgmventry() As MVEntry, ByRef imventry As Integer, ByRef MVObjectType As String) As Boolean Implements IMASynchronization.ResolveJoinSearch ' TODO: Add join resolution code here Throw New EntryPointNotImplementedException() End Function Public Sub MapAttributesForImport(ByVal FlowRuleName As String, ByVal csentry As CSEntry, ByVal mventry As MVEntry) Implements IMASynchronization.MapAttributesForImport ' TODO: write your import attribute flow code Throw New EntryPointNotImplementedException() End Sub Public Sub MapAttributesForExport(ByVal FlowRuleName As String, ByVal mventry As MVEntry, ByVal csentry As CSEntry) Implements IMASynchronization.MapAttributesForExport ' TODO: Add export attribute flow code here Select Case FlowRuleName Case "cd.user:accountExpires<-mv.person:employeeEndDate" If Not mventry("employeeEndDate").IsPresent Then csentry("accountExpires").IntegerValue = 0 Else If mventry("employeeEndDate").IsPresent Then Dim endDateSTR As String = mventry("employeeEndDate").Value Dim endDate As DateTime = DateTime.Parse(endDateSTR) Dim NewendDate As DateTime = endDate.AddYears(1) Dim NewendDateSTR As String = NewendDate.ToString csentry("accountExpires").IntegerValue = ConvertToFileTimeUtc(NewendDateSTR) End If End If Case Else Throw New EntryPointNotImplementedException() End Select End Sub Public Function Deprovision(ByVal csentry As CSEntry) As DeprovisionAction Implements IMASynchronization.Deprovision ' TODO: Remove this throw statement if you implement this method Throw New EntryPointNotImplementedException() End Function Private Function ConvertToFileTimeUtc(ByVal sourceval As String) As Long Return DateTime.Parse(sourceval).ToFileTimeUtc() End Function End Class
October 4th, 2011 3:04am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics