Imanami Community

Join or create discussions about common issues and solutions.
Welcome to Imanami Community Sign in | Join | Help
in Search

Adding Info to AD user properties

Last post 01-04-2008, 10:38 PM by Robert Haaverson. 8 replies.
Sort Posts: Previous Next
  •  11-07-2007, 5:40 AM 387

    Adding Info to AD user properties

    We have a DTM job to disable users but are trying to add a note under the Telephone user properties tab in AD.  We found the value to do this to be "info" but whenever it does add a comment it removes the existing notes.  Is there a way to append new notes to this field and leave the exiting?

     Sample transform script for what we have so far:

    DTM.Result = DTM.Source("TERMINATION_DATE")
    dim dToday As Date = Today
    if DTM.source("TERMINATION_DATE") <> ""
    DTM.Result = dToday & " Updated as per report"
    end if

     

     

    Thank you

  •  11-07-2007, 9:26 AM 397 in reply to 387

    Re: Adding Info to AD user properties

    This is a bit tricky:

    Dim sResult As String = ""
    Dim destination As DirectoryEntry = CType(DTM.Destination, DirectoryEntry) 
    If destination<>null Then
    sInfo = destination.Properties("info").Value.ToString()
    End If
    DTM.Result = DTM.Source("TERMINATION_DATE")
    dim dToday As Date = Today
    if DTM.source("TERMINATION_DATE") <> ""
    Dim sTerminated As String = dToday & " Updated as per report"
    If sInfo <> "" Then
    DTM.Result = sInfo & vbCRLF & sTerminated
    Else
    DTM.Result = sTerminated
    End If

    end if

    You may need some extra code to avoid the info attribute looking like this:

    10/27/2207 Updated as per report10/27/2207 Updated as per report10/27/2207 Updated as per report

     

  •  11-07-2007, 9:45 AM 398 in reply to 397

    Re: Adding Info to AD user properties

    Thanks for the reply

    When i click the test script it gives me an error 'destination' is already declared as a parameter of this method.

    On line 2: Dim destination as DirectoryEntry = Ctype(DTM.destination, DirectoryEntry) error#30734

  •  11-07-2007, 9:47 AM 399 in reply to 398

    Re: Adding Info to AD user properties

    Change the name of the variable to something else, maybe "de"?
  •  11-07-2007, 9:53 AM 400 in reply to 399

    Re: Adding Info to AD user properties

    Now i get compiler error 'DirectoryEntry' is not defined. Does anything need to be defined in the power tools?
  •  11-07-2007, 9:57 AM 401 in reply to 400

    Re: Adding Info to AD user properties

    Sorry, I should have typed it into the editor first.  I just recalled it from memory.  Change it to System.DirectoryServices.DirectoryEntry in both places.
  •  11-07-2007, 10:47 AM 402 in reply to 401

    Re: Adding Info to AD user properties

    I am now getting compile error type 'System.DirectoryServices.DirectoryEntry" is not defined

  •  11-07-2007, 9:17 PM 403 in reply to 402

    Re: Adding Info to AD user properties

    Woops, I reached a dead-end.  System.DirectoryServices.dll is not referenced in the script compiler.  I can't work around this in a transform.

     

    Excerpt from Help File:

    DTM establishes certain system assembly references before compiling your scripts. }}--> }}-->These references apply to all scripts and cannot be overridden. }}--> }}-->These references are:

    • MsCorLib.dll

    • System.dll

    • System.Data.dll

    • System.Xml.dll

    System.DirectoryServices, in particular, is “off-limits” to your scripts. }}--> }}-->This prevents direct access to ActiveDirectory and other LDAP data stores. }}--> }}-->This is a desirable restriction, as it prevents your script from acting in conflict with DTM – which, after all, has final responsibility for updating these data stores.

    .Net Namespaces

    DTM imports certain namespaces when compiling your scripts. }}--> }}-->These imports apply to all scripts and cannot be overridden. }}--> }}-->These imports are:

    • Imports System

    • Imports System.Text

    • Imports System.Text.RegularExpressions

    • Imports System.IO

    • Imports System.Math

     

  •  01-04-2008, 10:38 PM 444 in reply to 403

    Re: Adding Info to AD user properties

    Sorry for the delay, but I got it!  You have to map the Info to a field in the source but it will be ignored.  Then add the following script to eh GLobal Script Editor in the Row_Changing event:

    'Append a value
    Dim sTerminationDate As String = DTM.Source("TERMINATION_DATE")
    Dim sNotes As String = sTerminationDate & " Updated as per HRMS"
    Dim destinationFieldName As String = "info"
    If Not DbNull.Value.Equals(dtmsource.OriginalDestination(destinationFieldName)) Then
     If (dtmsource.OriginalDestination(destinationFieldName)<>"") And Not (dtmsource.OriginalDestination(destinationFieldName).EndsWith(sNotes))Then
             dtmsource.StagingDestination(destinationFieldName) = dtmsource.OriginalDestination(destinationFieldName) & vbCRLF & sNotes
           Else
                  dtmsource.StagingDestination(destinationFieldName) = dtmsource.OriginalDestination(destinationFieldName)
     End If
    End If

    The above script requires that you map the ActiveDirectory field “Info” to any field in the source.  The mapping will be ignored, but is required for the script to work.

     --Robert

     

View as RSS news feed in XML
Powered by Community Server (Personal Edition), by Telligent Systems