Identifying the Runnable initiated by Executor

Im trying out the Executor classes in java 1.5, constructing a pool of them with
  Executors.newFixedThreadPool(THREAD_POOL_SIZE);it is used to create whenever I need to invoke a Runnable() object
I have also used
Thread.Thread.setDefaultUncaughtExceptionHandler() to set a defaultexceptioon handler for uncaught exceptions.My question is how does the exceptionhandler identify which Runnable class is being run by the thread ?
Before I used Executor I would construct every Thread with a name from the Runnable() object I was invoking but with Executor you cannot specify a threadname (because It want to reuse a thread....) so how can I track back to the Runnable type.

OK, thanks Thread.currentThread().setName() does the
trick, does it matter if I dont set it back ?Not if you control all the tasks using the executor. It is only informational.
I will explain a bit more in case Im doing something
I shouldnt be, the application is a Swing Gui
application so whenever I want to run a task that may
take some time I run it within a seperate Thread (so
it isnt tying up the EventDispatchThread). A
particular task will only be invoked by one Thread at
any time , for example I have a loadFromFile() task,
there will never be multiple loadFromFile() tasks
running concurrently so I feel safe to set the Thread
name based on the Runnable classes name.Sounds like a SingleThreadedExecutor will do the job - which is only slightly different to a fixed pool of size 1. (The former always has 1 thread, the latter can be changed later.)
I was looking at The ExecutorService as a means to
reducing Thread allocation costs, because most of the
Threads are short living.Sure. If there is only one active task you just need one thread in the executor. It will get replaced if the task throws exceptions.

Similar Messages

  • Is there a way to identify the iTunes user?

    Since the StoreKit API does not return subscription InApp purchases during a restoreCompletedTransactions call, only way to know for sure that someone purchased an app is to tie the initial purchase to the iTunes account in the server (developer server) and restore the active subscriptions on all devices that use that iTunes account.
    Does the SDK provide for a call which will uniquely identify the user? Something like a UUID? The SDK provides for a unique device identifier but that is of no use to restore the subscriptions on the other devices the user may be using.
    I do not understand why Apple did not think of this case when they decided not to support Subscription InApp purchases in the call to query for completed transactions. This is insane and short-sighted on part of Apple with no thought given to the developers needs.
    -TRS

    I have been working to create such a solution when Submit All first appeared, but that version was pretty buggy and I never got back to it. Maybe it is possible, but I cannot guarantee you that it can. When trying I have spent many hours to fix it without success. For the moment I don't have any incentive to restart with that problem. Hope you or some other user has more courage.

  • How do I identify the latest file modifications, application install, and registry key modification for Security Forensics.... using GP Audit for registry/file system

    Hello,
    Title pretty much states it all. I initially set out (as part of a Security Forensics initiative) to identify the most recently installed applications, modified files, and registry key changes using PowerShell. I attempted to pull this information and sort
    them by date installed/last modified, but it was brought to my attention this information isn't always present and can be modified - so it's not accurate.
    At that time it was suggested we use Group Policy auditing for Registry and File System -  but I'm not sure how I'm going to use/pull these in PowerShell? This will be used on remote host all over the world so local physical access isn't an option.
    My question is:
    Once Group Policy Auditing for Registry and File System has been enabled, how would I go about pulling those audit logs for review once a system has been identified as compromised? I'm brand new to this GP Auditing (we have a separate team for that) so feel
    free to take it from the beginning. :)
    Thanks in advance!

    Hi,
    Here are a few suggestions for you:
    Ensure Remote Registry service is started on local and remote machines.
    Add the – Credential option and supply administrative credentials within the command.
    More information for you:
    Get-Eventlog doesn't work against Vista/W7 clients
    https://social.technet.microsoft.com/Forums/en-US/c5185a01-b0d2-49a7-9aa7-52e6534ada04/geteventlog-doesnt-work-against-vistaw7-clients?forum=winserverpowershell
    PowerShell - How to Get XML EventData - Remote Eventlogs - Exchange Events
    https://social.technet.microsoft.com/Forums/scriptcenter/en-US/382b10c9-d740-46b1-b81c-b24de911eb14/powershell-how-to-get-xml-eventdata-remote-eventlogs-exchange-events-?forum=ITCG
    Powershell script to gather failed logon attempts by event id and type from the security events log
    https://social.technet.microsoft.com/Forums/scriptcenter/es-ES/00a62492-c63a-4c8b-92f9-1cc857223a00/powershell-script-to-gather-failed-logon-attempts-by-event-id-and-type-from-the-security-events-log?forum=ITCG
    Best Regards,
    Amy
    Please remember to mark the replies as answers if they help and un-mark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected]

  • To identify the roles

    Dear Experts,
    I am presently creating the workflow template for mapping the (FI)reconciliation process of GL's. The scenario what I am having is for a GL, different reconciler roles and approver roles have been assigned(tran PO13). The process is as defined below
    The workflow will be initiated in the background for an event. Each GL has to be approved by the reconcilers assigned. After each reconciler, Approvers has to approve the same as assigned in the Organization Object. A single reconciler can have multiple approvers and viceversa als. How we will be able to identify the Reconciler or Approvers in runtime inorder to map the workflow process?
    Can anyone help me with some sample codes for the same.
    Thanks in advance.
    Regards
    Cesil

    hi,
    the problem is there are multiple approvers.
    lets look this way :
    event gets triggered, and  'n' GLs are output
    N ' GLs are input for  'm' Reconcilers
    m' reconcilers have 'p' approvers and here the relation is m<-> p.
    so create two separate roles for both reconcilers and  Approvers.and each reconciler is related to one or more approvers.and vice versa.
    lets take n= 3.
    so create a multi container element, so that multiple workitems get created  for each of the reconciler , and create a mutli container element so that multiple workitem gets created for each of the approvers.and the concerned approver can be found out using the rule.If there are multiple approvers, then multiple workitems are sent.Here a use a flag such that dependent on the number of approvers, that many workitems are created.
    even though reconciler and approvers have one to many relation, this can be sorted placing fork at reconciler and approver level.
    and individually,in the container depending on the workitem, we can find out the reconciler and approver for every gl.
    i hope this answers your query.
    Regards,
    Saujanya

  • How to identify the DDL changes ?

    Hi all,
    How to identify the DDL changes done to the database ?
    By triggers only Or we can use Logminer also OR
    SELECT * FROM USER_OBJECTS where object_type = 'TABLE' order by LAST_DDL_TIME desc;
    OR
    is there any other options are available ?
    Thanks in advance,
    Pal

    Something from asktom might help
    tkyte@TKYTE816> create or replace trigger ddl_trigger
    2 after create or alter or drop on SCHEMA
    3 declare
    4 l_sysevent varchar2(25);
    5 l_extra varchar2(4000);
    6 begin
    7 select ora_sysevent into l_sysevent from dual;
    8
    9 if ( l_sysevent in ('DROP','CREATE') )
    10 then
    11 if l_sysevent = 'CREATE'
    12 then
    13 begin
    14 select 'storage ( initial ' || initial_extent ||
    15 ' next ' || next_extent || ' .... )'
    into l_extra
    16 from all_tables
    where table_name = ora_dict_obj_name
    17 and owner = user;
    18 exception
    19 when no_data_found then null;
    20 end;
    21 end if;
    22
    23 insert into log
    24 select ora_sysevent, ora_dict_obj_owner,
    25 ora_dict_obj_name, l_extra
    26 from dual;
    27 elsif ( l_sysevent = 'ALTER' )
    28 then
    29 insert into log
    30 select ora_sysevent, ora_dict_obj_owner,
    31 ora_dict_obj_name, sql_text
    32 from v$open_cursor
    33 where upper(sql_text) like 'ALTER%' ||
    34 ora_dict_obj_name || '%'
    35 and sid = ( select sid
    36 from v$session
    37 where audsid=userenv('sessionid') );
    38 end if;
    39 end;
    40 /

  • Identifying the Side Panel role from NWBC

    When an authorized user execute a Tcode with Side Panel assigned, the Side Panel will appear.
    Question - Is there a standard report\mechanics whereby one could identify the Side Panel role associated with that Tcode?
    Currently, my only method is to a brute search for the Application Alias via table AGR_HIER.   And then using description of the node to try to deduce what the Role is.  Works OK, but not exactly the most direct approach.
    Cheers
    Damean

    This report lists all roles with a classic transaction as a triggering condition, either linked directly as APPLICATION_ALIAS or through the node ID.
    report  zlistroles.
    types: begin of nodefields,
      agr_name   type agr_name,
      object_id  type menu_num_8,
      reporttype type reporttype,
      report     type extdreport,
      appl_alias type menu_details_alias,
    end of nodefields.
    data lt_nodes   type table of nodefields.
    data ls_nodes   type          nodefields.
    data ls_nodes2  type          nodefields.
    data lv_objid   type menu_num_8.
    data lt_results type table of string.
    data ls_results type string.
    data lv_alias   type menu_details_alias.
    data ls_match   type match_result.
    data lv_length  type i.
    select agr_name object_id reporttype report appl_alias
      from agr_hier into corresponding fields of table lt_nodes.
    loop at lt_nodes into ls_nodes where appl_alias is not initial.
      if ls_nodes-appl_alias cp '{*}'.
        find first occurrence of regex `\{[0-9]{1,3}\}` in ls_nodes-appl_alias results ls_match.
        if sy-subrc eq 0.
          lv_length = ls_match-length - 1.
          lv_objid = ls_nodes-appl_alias+1(lv_length).
          read table lt_nodes into ls_nodes2 with key  agr_name = ls_nodes-agr_name
                                                      object_id = lv_objid.
          if sy-subrc eq 0 and
             ls_nodes2-reporttype eq 'TR'.
            write: / ls_nodes2-agr_name,
                     ls_nodes2-report.
          endif.
        else.
          find first occurrence of regex `\{TR=(.*)\}` in ls_nodes-appl_alias results ls_match.
          if sy-subrc eq 0.
            lv_length = ls_match-length - 5.
            lv_alias = ls_nodes-appl_alias+4(lv_length).
            split lv_alias at ';' into table lt_results.
            loop at lt_results into ls_results.
              write: / ls_nodes-agr_name,
                       ls_results.
            endloop.
          endif.
        endif.
      endif.
    endloop.

  • How do you identify the Logical system in start routine of a transformation

    My scenario is this.  I have five r3 systems that I am extracting from.   In the start routine of the transformation from the r3 data source to my data store I  am going to delete data and I need to know the source system id.    How do I identify the logical system or source system id in the transformation.  Is there a system field that contains this information.    I do not want to hard code the source system id in the routine.

    hi
    have a lool at tables rsreqdone and rsbkrequest with a join you should be able to determine the source.
    regards
    Boujema
    How to give points: Mark your thread as a question while creating it. In the answers you get, you can assign the points by clicking on the stars to the left. You also get a point yourself for rewarding (one per thread).
    Edited by: Boujema Bouhazama on May 9, 2008 12:04 AM

  • Is there any way to identify the particular socket connection is closed ?

    Is there any way to identify the particular socket connection is closed or not ?
    Any methods ???
    How can the program knows the connection is lost or some thing ...
    Is the socket throws some excpetions when there is no active connection ???
    namanc

    If you get an IOException when you try to use the socket, the connection was obviously closed.
    The correct way for an application to know if the socket was closed is:
    1) the server sends a message indicating that the socket should be closed
    2) the client closes the socket itself

  • Identify the last data package in start routine

    Hi Everyone
    We have a start routine in transformations. We require to do some special processing in the start routine only when the last data package is executing. How can we determine in the start routine that current package is last one or not ? Any pointers in this direction are appreciated.

    Hi,
    You can get packet Id from datapackid in start routine and end routine. But I'm not so sure how to identify the last packet ID, alternatively you can store this packet id in some where else and read the same value in End routine if your logic(processing) permits to do this in End routine instead of Start routine.
    METHODS
          start_routine
            IMPORTING
              request                  type rsrequest
              datapackid               type rsdatapid
            EXPORTING
              monitor                  type rstr_ty_t_monitors
            CHANGING
              SOURCE_PACKAGE              type tyt_SC_1
            RAISING
              cx_rsrout_abort.
    hope it helps...
    regards.
    Raju

  • Need a script to update AD information from Excel file, however employee ID is use for identify the user in AD

    Please help me to get this done!....Thanks in Advance
    This is current script I use to update AD record but its taking user id to pick the user in AD, which is some time give error not update properly..
    # UpdateUsers.ps1
    # PowerShell program to update Active Directory users from the information in a
    # Microsoft Excel spreadsheet. Only single-valued string attributes supported.
    # Author: Richard Mueller
    # PowerShell Version 1.0
    # September 12, 2011
    Trap
        If ("$_".StartsWith("Cannot load COM type Excel.Application"))
            "Excel application not found, program aborted"
            Add-Content -Path $LogFile -Value "## Excel application not found"
            Add-Content -Path $LogFile -Value "   $_"
            Add-Content -Path $LogFile -Value $("Program aborted: " + (Get-Date).ToString())
            Break
        If (("$_".StartsWith("Exception has been thrown")) -and ($Step -eq "4"))
            "Excel spreadsheet not found, program aborted"
            Add-Content -Path $LogFile -Value "## Excel spreadsheet not found: $ExcelPath"
            Add-Content -Path $LogFile -Value "   $_"
            Add-Content -Path $LogFile -Value $("Program aborted: " + (Get-Date).ToString())
            Break
        If ("$_".StartsWith("The server is not operational"))
            "Domain Controller not found, program aborted"
            Add-Content -Path $LogFile -Value "## Domain Controller not found"
            Add-Content -Path $LogFile -Value "   $_"
            Add-Content -Path $LogFile -Value $("Program aborted: " + (Get-Date).ToString())
            Break
        If ("$_".StartsWith("The directory service is unavailable"))
            "Active Directory not found, program aborted"
            Add-Content -Path $LogFile -Value "## Active Directory not found"
            Add-Content -Path $LogFile -Value "   $_"
            Add-Content -Path $LogFile -Value $("Program aborted: " + (Get-Date).ToString())
            Break
        If ("$_".StartsWith("The specified domain"))
            "Domain not found, program aborted"
            Add-Content -Path $LogFile -Value "## Domain not found"
            Add-Content -Path $LogFile -Value "   $_"
            Add-Content -Path $LogFile -Value $("Program aborted: " + (Get-Date).ToString())
            Break
        "Unexpected error: $_"
        Add-Content -Path $LogFile -Value "## Unexpected error: $_"
        Add-Content -Path $LogFile -Value "   Step: $Step"
        Break
    Function CleanUp
        Trap
            "Error during cleanup: $_"
            Add-Content -Path $LogFile -Value "## Error during cleanup: $_"
            $Script:Errors = $Script:Errors + 1
            Continue
        # Function to release Excel objects from memory.
        Do {$x = [System.Runtime.InteropServices.Marshal]::ReleaseComObject($Columns)} While ($x -gt -1)
        Do {$x = [System.Runtime.InteropServices.Marshal]::ReleaseComObject($Rows)} While ($x -gt -1)
        Do {$x = [System.Runtime.InteropServices.Marshal]::ReleaseComObject($Range)} While ($x -gt -1)
        Do {$x = [System.Runtime.InteropServices.Marshal]::ReleaseComObject($Sheet)} While ($x -gt -1)
        Do {$x = [System.Runtime.InteropServices.Marshal]::ReleaseComObject($Worksheets)} While ($x -gt -1)
        $Workbook.Close($False)
        Do {$x = [System.Runtime.InteropServices.Marshal]::ReleaseComObject($Workbook)} While ($x -gt -1)
        Do {$x = [System.Runtime.InteropServices.Marshal]::ReleaseComObject($Workbooks)} While ($x -gt -1)
        $Excel.Quit()
        Do {$x = [System.Runtime.InteropServices.Marshal]::ReleaseComObject($Excel)} While ($x -gt -1)
    # Specify paths to spreadsheet and log file.
    $Script:Errors = 0
    $Step = "1"
    $ExcelPath = "c:\scripts\UpdateUsers.xls"
    $LogFile = "c:\scripts\UpdateUsers.log"
    Write-Host "Please Standby..."
    # Add to the log file.
    $Step = "2"
    Add-Content -Path $LogFile -Value "------------------------------------------------" -ErrorAction Stop
    Add-Content -Path $LogFile -Value "UpdateUsers.ps1 Version 1.0 (September 12, 2011)"
    Add-Content -Path $LogFile -Value $("Started: " + (Get-Date).ToString())
    Add-Content -Path $LogFile -Value "Spreadsheet: $ExcelPath"
    Add-Content -Path $LogFile -Value "Log file: $LogFile"
    $Step = "3"
    # Open specified Excel spreadsheet.
    $Excel = New-Object -ComObject "Excel.Application"
    $Workbooks = $Excel.Workbooks
    $Step = "4"
    $Workbook = $Workbooks.Open($ExcelPath)
    $Worksheets = $Workbook.Worksheets
    $Sheet = $Worksheets.Item(1)
    $Range = $Sheet.UsedRange
    $Rows = $Range.Rows
    $Columns = $Range.Columns
    $Step = "5"
    # Hash table of attribute syntaxes.
    # The LDAP display names will be read from the spreadsheet.
    # The corresponding syntaxes will be read from the Schema container.
    $Attributes = @{}
    # Array of spreadsheet column headings.
    $Cols = @()
    $Step = "6"
    # Read attribute LDAP Display Names from the first row of the spreadsheet.
    $ID = 0
    For ($k = 1; $k -le $Columns.Count; $k = $k + 1)
        # Retrieve column heading, the lDAPDisplayName of an attribute.
        $Value = $Sheet.Cells.Item(1, $k).Text
        # Keep track of all column headings.
        $Cols += $Value
        # Skip duplicates in hash table.
        If ($Attributes.ContainsKey($Value) -eq $False)
            # Default is "NotFound", until found in the AD Schema.
            $Attributes.Add($Value, "NotFound")
        # Keep track of which column uniquely identifies users.
        If ($Value.ToLower() -eq "distinguishedname") {$ID = $k}
        If (($Value.ToLower() -eq "samaccountname") -and ($ID -eq 0)) {$ID = $k}
        # This script cannot be used to rename users.
        If ($value.ToLower() -eq "cn")
            Add-Content -Path $LogFile -Value "## This script cannot be used to rename users"
            Add-Content -Path $LogFile -Value "   Do not specify the cn attribute in the spreadsheet"
            Add-Content -Path $LogFile -Value $("Program aborted: " + (Get-Date).ToString())
            CleanUp
            Return "Program aborted: cn attribute found in spreadsheet" `
                + "`nSee log file: $LogFile"
    $Step = "7"
    If ($ID -eq 0)
        Add-Content -Path $LogFile -Value "## No column found to identify users"
        Add-Content -Path $LogFile -Value "   One column must be distinguishedName or sAMAccountName"
        Add-Content -Path $LogFile -Value $("Program aborted: " + (Get-Date).ToString())
        CleanUp
        Return "Program aborted: No column found in spreadsheet to identify users" `
            + "`nSee log file: $LogFile"
    # Create filter to query for attributes in the schema.
    $Attrs = $Attributes.Keys
    $Filter = "(&(objectCategory=AttributeSchema)(|"
    ForEach ($Attr In $Attrs)
        $Filter = $Filter + "(lDAPDisplayName=$Attr)"
    $Filter = $Filter + "))"
    $Step = "8"
    $RootDSE = [System.DirectoryServices.DirectoryEntry]([ADSI]"LDAP://RootDSE")
    $Domain = $RootDSE.Get("defaultNamingContext")
    $Schema = $RootDSE.Get("schemaNamingContext")
    $Step = "9"
    # Use the NameTranslate object.
    $objTrans = New-Object -comObject "NameTranslate"
    $objNT = $objTrans.GetType()
    # Initialize NameTranslate by locating the Global Catalog.
    $objNT.InvokeMember("Init", "InvokeMethod", $Null, $objTrans, (3, $Null))
    $Step = "10"
    # Retrieve NetBIOS name of the current domain.
    $objNT.InvokeMember("Set", "InvokeMethod", $Null, $objTrans, (1, "$Domain"))
    $NetBIOSDomain = $objNT.InvokeMember("Get", "InvokeMethod", $Null, $objTrans, 3)
    Add-Content -Path $LogFile -Value "NetBIOS name of domain: $NetBIOSDomain"
    $Step = "11"
    $Searcher = New-Object System.DirectoryServices.DirectorySearcher
    $Searcher.SearchRoot = [ADSI]"LDAP://$Schema"
    $Searcher.PageSize = 200
    $Searcher.SearchScope = "subtree"
    $Searcher.PropertiesToLoad.Add("lDAPDisplayName") > $Null
    $Searcher.PropertiesToLoad.Add("attributeSyntax") > $Null
    $Searcher.PropertiesToLoad.Add("isSingleValued") > $Null
    $Searcher.PropertiesToLoad.Add("systemFlags") > $Null
    # Filter on specified attributes.
    $Searcher.Filter = $Filter
    $Step = "12"
    # Query Active Directory.
    $Results = $Searcher.FindAll()
    # Enumerate recordset.
    ForEach ($Result In $Results)
        # Retrieve properties of attributes.
        $Name = $Result.Properties.Item("lDAPDisplayName")[0]
        $SysFlags = $Result.Properties.Item("systemFlags")[0]
        $SyntaxNum = $Result.Properties.Item("attributeSyntax")[0]
        $SingleValued = $Result.Properties.Item("isSingleValued")[0]
        # Only single-valued string attributes supported by this version of the program.
        Switch ($SyntaxNum)
            "2.5.5.12" {$Syntax = "String"}
            Default {$Syntax = "NotSupported"}
        If ($Name.ToLower() -eq "distinguishedname") {$Syntax = "DN"}
        If (($SysFlags -band 4) -ne 0)
            $Attributes[$Name] = "Constructed"
        Else
            If ($SingleValued -eq $True)
                $Attributes[$Name] = $Syntax
            Else
                $Attributes[$Name] = "NotSupported"
    $Step = "13"
    # Check if any attributes not found or have unsupported syntax.
    $Found = $True
    ForEach ($Attr In $Attrs)
        $Syntax = $Attributes[$Attr]
        If ($Syntax -eq "NotFound")
            Add-Content -Path $LogFile -Value "## Attribute $Attr not found in schema"
            "Attribute $Attr not found in schema"
            $Found = $False
        If ($Syntax -eq "NotSupported")
            Add-Content -Path $LogFile -Value "## Attribute $Attr has a syntax that is not supported"
            "Attribute $Attr has a syntax that is not supported"
            $Found = $False
        If ($Syntax -eq "Constructed")
            Add-Content -Path $LogFile -Value "## Attribute $Attr is operational, so is not supported"
            "Attribute $Attr is operational, so is not supported"
            $Found = $False
    $Step = "14"
    If ($Found -eq $False)
        Add-Content -Path $LogFile -Value $("Program aborted: " + (Get-Date).ToString())
        CleanUp
        Return "Program aborted" `
            + "`nSee log file: $LogFile"
    # Read remaining rows of the spreadsheet, until the first blank value is found
    # in the column that identifies users.
    $Step = "15"
    $Script:Updated = 0
    $Script:Unchanged = 0
    $j = 2
    Do {
        # Retieve ID value for the user first.
        $Value = $Sheet.Cells.Item($J, $ID).Text
        $Found = $False
        $Step = "16"
        If ($Cols[$ID - 1] -eq "distinguishedname")
            # Any forward slash characters must be escaped.
            $DN = $Value.Replace("/", "\/")
            # Bind to the user object.
            # If user not found, $User.Name will be $Null.
            $User = [ADSI]"LDAP://$DN"
            If ($User.Name -ne $Null)
                $Found = $True
        $Step = "17"
        If ($Cols[$ID - 1] -eq "samaccountname")
            Trap
                Write-Host ""
                "Error translating name: $_"
                Add-Content -Path $LogFile -Value "## Error translating name $Value"
                Add-Content -Path $LogFile -Value "   Description: $_"
                $Script:Errors = $Script:Errors + 1
                Continue
            # Convert sAMAccountName to distinguishedName.
            $DN = ""
            $Step = "18"
            $objNT.InvokeMember("Set", "InvokeMethod", $Null, $objTrans, (3, "$NetBIOSDomain$Value"))
            $DN = $objNT.InvokeMember("Get", "InvokeMethod", $Null, $objTrans, 1)
            $Step = "19"
            If ($DN -ne "")
                $Step = "20"
                # Any forward slash characters must be escaped.
                $DN = $DN.Replace("/", "\/")
                # Bind to the user object.
                $User = [ADSI]"LDAP://$DN"
                $Found = $True
        If ($Found -eq $True)
            $Step = "21"
            # Read remaining values for this user.
            $Changed = $False
            For ($k = 1; $k -le $Columns.Count; $k = $k + 1)
                # Skip the identifying column.
                If ($k -ne $ID)
                    $Step = "22"
                    # Retrieve attribute name for this column from array.
                    $AttrName = $Cols[$k - 1]
                    # Retrieve attribute syntax from hash table.
                    $Syntax = $Attributes[$AttrName]
                    $Step = "23"
                    # Retrieve attribute value for this user.
                    $Value = $Sheet.Cells.Item($j, $k).Text
                    # Skip blank values.
                    If ($Value -ne "")
                        If ($Syntax -eq "String")
                            Trap
                                If ("$_".StartsWith("The directory property cannot be found"))
                                    Continue
                                Else
                                    Write-Host ""
                                    "Error retrieving value from Active Directory: $_"
                                    Add-Content -Path $LogFile -Value "## Error retrieving $AttrName for user $DN"
                                    Add-Content -Path $LogFile -Value "   Description: $_"
                                    $Script:Errors = $Script:Errors + 1
                                    Continue
                            $Step = "24"
                            # Single-valued string attribute.
                            # Retrieve existing value.
                            $OldValue = ""
                            $OldValue = $User.Get($AttrName)
                            # Check if existing value to be deleted.
                            If ($Value.ToLower() -eq ".delete")
                                If ($OldValue -ne "")
                                    If ($AttrName.ToLower -eq "samaccountname")
                                        Add-Content -Path $LogFile -Value `
                                            "## Mandatory attribute sAMAccountName cannot be cleared for user: $DN"
                                        $Script:Errors = $Script:Errors + 1
                                    Else
                                        Trap
                                            Write-Host ""
                                            "Error deleting value from Active Directory: $_"
                                            Add-Content -Path $LogFile -Value "## Error deleting $AttrName for user $DN"
                                            Add-Content -Path $LogFile -Value "   Description: $_"
                                            $Script:Errors = $Script:Errors + 1
                                            Continue
                                        $Step = "25"
                                        # Make the attribute value "not set".
                                        $User.PutEx(1, $AttrName, 0)
                                        $Changed = $True
                            Else
                                $Step = "26"
                                # Check if new value from spreadsheet different.
                                If ($Value -ne $OldValue)
                                    Trap
                                        Write-Host ""
                                        "Error assigning value from Active Directory: $_"
                                        Add-Content -Path $LogFile -Value "## Error assigning $AttrName for user $DN"
                                        Add-Content -Path $LogFile -Value "   Description: $_"
                                        $Script:Errors = $Script:Errors + 1
                                        Continue
                                    # Assign the new value to the attribute.
                                    $User.Put($AttrName, $Value)
                                    $Changed = $True
                        Else
                            # Unexpected error.
                            Add-Content -Path $LogFile -Value `
                                "## Unexpected syntax: $Syntax for attribute $AttrName for user $DN"
                            $Script:Errors = $Script:Errors + 1
            If ($Changed -eq $True)
                Trap
                    Write-Host ""
                    "Error saving to Active Directory: $_"
                    Add-Content -Path $LogFile -Value "## Error saving to AD for user $DN"
                    Add-Content -Path $LogFile -Value "   Description: $_"
                    $Script:Errors = $Script:Errors + 1
                    $Script:Updated = $Script:Updated - 1
                    Continue
                $User.SetInfo()
                Add-Content -Path $LogFile -Value "Update user: $DN"
                Write-Host "." -NoNewLine
                $Script:Updated = $Script:Updated + 1
            Else
                Add-Content -Path $LogFile -Value "User unchanged: $DN"
                Write-Host "." -NoNewLine
                $Script:Unchanged = $Script:Unchanged + 1
        Else
            Add-Content -Path $LogFile -Value "## User not found: $Value"
            Write-Host "." -NoNewLine
            $Script:Errors = $Script:Errors + 1
        $j = $J + 1
    } Until ($Sheet.Cells.Item($j, $ID).Text -eq "")
    $Step = "27"
    CleanUp
    Add-Content -Path $LogFile -Value $("Finished: " + (Get-Date).ToString())
    Add-Content -Path $LogFile -Value "Number of users updated: $Script:Updated"
    Add-Content -Path $LogFile -Value "Number of users unchanged: $Script:Unchanged"
    Add-Content -Path $LogFile -Value "Number of errors: $Script:Errors"
    Write-Host ""
    "Done"
    "Number of errors: $Script:Errors"
    "See log file: $LogFile"

    Actually scripts run fine with excel file, currently we are using user-id to pick to update AD. Now we want to update AD use employee id. You can say to identify the record in AD through employee ID instead of user-id. 
    I do not think you will get anyone here to fix that for you.  You need to find someone who knows PowerShell to help you or learn PowerShell your self.
    I would fix it for you but not for free.  It is too oddly designed and has too many dependencies.  Any small change is likely to break it.
    ¯\_(ツ)_/¯

  • How to identify the Open Schedule Lines.

    Hi All,
    I am writing an ABAP report which requires to identify the OPEN SALES ORDER SCHEDULE LINES.
    The requirement is to identify the Open Sales Order Schedule Lines for a particular month (user Processing month in the selection screen).  Here the Schedules line item could have been delivered already.  If it is not Billed then it is OPEN schedule line.
    Can anyone help me to understand the logic which I need to apply to identify only the Open sales order scshedule lines.
    I am using the following tables:
    VBAK,VBAP,VBUK,VBUP,VBEP.  Is there any other table which I need to use?  I am trying to avoid using table VBFA due to performance issues.
    Thanks in Advance
    Regards
    Gopalakrishnan S

    Hi Gopal,
    If you want to find status of any sales order line item then you can find from following method from VBUP table.
    In VBUP table there is a field FKSTK.By this filed status we can find billing status of particular sale order and this field has four possible values and these are
    <i><b>field value  field value meaning</b></i>                             
    if this value is space then order is not Not Relevant for billing             
    if this value is  'A'  then order is    Not yet processed
    if this value is   'B' then order is Partially processed
      if this value is  'C' then order   Completely processed
    If you want to find status for the header then go to VBUK table and process is same as above.
    In these table we can find all types of status.
    Message was edited by:
            shyla kumar
    Message was edited by:
            shyla kumar
    Message was edited by:
            shyla kumar

  • Unable to identify the exchange protocol of the message (sync AS2 MDN)

    Hi,
    We got the following error:
    Description: Unable to identify the exchange protocol of the message
    StackTrace:
    Error -: AIP-50080: Exchange protocol identification error
         at oracle.tip.adapter.b2b.engine.Engine.processIncomingMessage(Engine.java:1367)
         at oracle.tip.adapter.b2b.msgproc.Request.postTransmit(Request.java:2370)
         at oracle.tip.adapter.b2b.msgproc.Request.outgoingRequestPostColab(Request.java:1813)
         at oracle.tip.adapter.b2b.msgproc.Request.outgoingRequest(Request.java:968)
         at oracle.tip.adapter.b2b.engine.Engine.processOutgoingMessage(Engine.java:1152)
         at oracle.tip.adapter.b2b.xmlgwIntg.XMLGWIntegration.raiseOutboundMessage(XMLGWIntegration.java:168)
         at oracle.tip.adapter.b2b.xmlgwIntg.Outbound.onMessage(Outbound.java:297)
         at oracle.jms.AQjmsListenerWorker.dispatchOneMsg(AQjmsListenerWorker.java:316)
         at oracle.jms.AQjmsListenerWorker.run(AQjmsListenerWorker.java:129)
         at java.lang.Thread.run(Thread.java:534)
    Here is the Wire message (sync MDN)
    =======================
    Message-ID=<23033756.391232032071968.JavaMail.SYSTEM@INUBITTEST>
    Subject=Your ORDERS AS2
    [email protected]
    Content-Length=1347
    MIME-Version=1.0
    Server=Apache
    Date=Thu, 15 Jan 2009 15:07:52 GMT
    Content-Type=multipart/mixed;      boundary="----=_Part_53998_23619909.1232032071968"
    [email protected]
    ------=_Part_53998_23619909.1232032071968
    Content-Type: text/plain; charset=UTF-8; name=test.txt
    Content-Transfer-Encoding: 7bit
    Content-Disposition: attachment; filename=test.txt
    Message-ID: <17080722.371232032071906.JavaMail.SYSTEM@INUBITTEST>
    MIME-Version: 1.0
    Content-Type: multipart/report; report-type=disposition-notification;
         boundary="----=_Part_53997_14786767.1232032071906"
    AS2-Version: 1.1
    AS2-From: test_AS2
    AS2-To: as2me
    ------=_Part_53997_14786767.1232032071906
    Content-Type: text/plain; charset=us-ascii
    Content-Transfer-Encoding: 7bit
    MDN for Message ID: <33156:4:0:137@as2me>
    From: as2me
    To: test_AS2
    Received on: Thu, 15 Jan 2009 16:07:51 +0100
    Status: processed
    Comment: This is not a guarantee that the message has
    been completely processed or unterstood.
    ------=_Part_53997_14786767.1232032071906
    Content-Type: message/disposition-notification
    Content-Transfer-Encoding: 7bit
    Reporting-UA: inubit Integration Server
    Original-Recipient: rfc822; test_AS2
    Final-Recipient: rfc822; test_AS2
    Original-Message-ID: <33156:4:0:137@as2me>
    Disposition: automatic-action/MDN-sent-automatically; processed
    Received-Content-MIC: 5kFOLMXOUurpm6DUTA8IMRj5gcs=, sha1
    ------=_Part_53997_14786767.1232032071906--
    ------=_Part_53998_23619909.1232032071968--
    ============================
    The communication with our TP is going well, we are able to send, receive messages over AS2 and send back MDN, but we are not able
    to receive their MDN.
    Edit:
    It seems that after the latest MLR patch, the error changed to [IPT_HttpSendError] HTTP encounters send error :. Premature EOF encounter but the roots seem to lead to the problem with MDN as B2B is sending the message a couple of times now and gives the mentioned EOF error.
    Please advise,
    Thank you
    Edited by: Kamil Zadora on Jan 30, 2009 3:44 AM

    Hi Ramesh,
    Yes, agreement uses AS2 IDentifiers. Incoming messages are recognized correctly, and we send back sync MDN that is correctly received by our TP. They also recieve our messages correctly although Oracle B2B does not recognize the MDN from them. I think that this causes that, now after applying the latest MLR patch, B2B tries to send it around 6 times and gives the Unexpected EOF error.
    Thank you for your help in advance,
    Kind regards,

  • Identify the relationship for the follwing fields

    Hi experts,
    I have to develop a report which is taking input as : -
    1.matnr (material number)
    2.werks (plant)
    3.stlan (BOM usage)
    4. stlal (alternative)
    And I need the output as : -
    AENNR (ECR : engg change request)
    I am unable to identify the relationships between these fields, plz suggest me the best ways to do this..
    Thanks in advance
    Gaurav
    Moderator message : Spec-dumping not allowed. Read forum rules before posting. Thread locked.
    Edited by: Vinod Kumar on Jul 5, 2011 2:11 PM

    after getting the records to internal table write the statement
    delete adjacent duplicate ................... before that write sort stament also......
    Deleting Adjacent Duplicate Entries
    To delete adjacent duplicate entries use the following statement:
    DELETE ADJACENT DUPLICATE ENTRIES FROM <itab>
                                      [COMPARING <f1> <f 2> ...
                                                 |ALL FIELDS].
    The system deletes all adjacent duplicate entries from the internal table <itab>. Entries are duplicate if they fulfill one of the following compare criteria:
    Without the COMPARING addition, the contents of the key fields of the table must be identical in both lines.
    If you use the addition COMPARING <f1> <f 2> ... the contents of the specified fields <f 1 > <f 2 > ... must be identical in both lines. You can also specify a field <f i > dynamically as the contents of a field <n i > in the form (<n i >). If <n i > is empty when the statement is executed, it is ignored. You can restrict the search to partial fields by specifying offset and length.
    If you use the addition COMPARING ALL FIELDS the contents of all fields of both lines must be identical.
    You can use this statement to delete all duplicate entries from an internal table if the table is sorted by the specified compare criterion.
    If at least one line is deleted, the system sets SY-SUBRC to 0, otherwise to 4.

  • To identify the user running the job at runtime

    Hi All,
    My requirement is to develop a program which need to send mail only if a particular user runs the job.
    I need to read the user who runs the job at runtime, i tried with SY-UNAME but it holds the user name of the person who created the job at runtime.
    Please suggest me the possible ways of identifying the user running the job at runtime.
    Thanks in advance!!!
    Regards,
    Dinesh.

    "I need to read the user who runs the job at runtime, i tried with SY-UNAME but it holds the user name of the person who created the job at runtime."
    This is not true if your program/form/method is called inside the ABAP report which is executing in the batch job step. There, the active SY-UNAME is the user entered in SM36 as the job step user. It is not the user who planned/scheduled the job.
    It is unclear from your description where your program is actually running. Is it another (ABAP) step belonging to the same job or is it actually some routine called within the same job step that you are checking or is it a program totally unrelated to the batch job in question (in that case, check out the other answers about TBTCO/TBTCP)
    - Alex

  • How can we  identify the mails from the mails that have been read previousy

    Hi
    i m using java mail api to fetch the mails. but i am facing a problem that is every time i fetch all the mails in my application.
    Is there any way by which i can set a flag or something so as to i can identify the mails which have been processed earliar.
    please help me out.
    Dushyant Kumar

    POP3, right? See the JavaMail FAQ.

Maybe you are looking for