locked
setinfo(); The specified directory service attribute or value does not exist. RRS feed

  • Question

  • I would like to determine the wrong ATTRIBUTE NAME from the exception object (I would like to log the error...)

    try {
    $Searcher = New-Object -TypeName System.DirectoryServices.DirectorySearcher
    ...
    $result = $Searcher.FindOne().GetDirectoryEntry()
    $result.putex( 2, 'Title' , 'New title' )
    $result.putex( 1, 'Deeeeeeeescription' , $null ) # I misspelled it... to get an error...
    
    $result.setinfo()
    } catch {
    $err = $_
    }
    # I can get the error message...
    $err.Exception.InnerException     # Error: The specified directory service attribute or value does not exist.
    
    # Hot to find out which attribute? (in this case I should find: 'Deeeeeeeescription' )



    • Edited by PSAmator Tuesday, November 27, 2018 10:49 AM
    • Edited by jrv Tuesday, November 27, 2018 2:47 PM Fixed title
    Tuesday, November 27, 2018 10:48 AM

Answers

  • My recollection is that the error is not raised until the SetInfo method is invoked. I don't believe there is a way to determine which attribute name causes the problem, except to invoke SetInfo separately for each attribute. For example, similar to:

    Try {$result.putex( 2, 'Title' , 'New title' )
        $result.setinfo()}
    Catch {"Error in title"}
    
    Try {$result.putex( 1, 'Deeeeeeeescription' , $null )
        $result.setinfo()}
    Catch {"Error in Deeeeeeeescription"}
    


    Richard Mueller - MVP Enterprise Mobility (Identity and Access)

    • Marked as answer by PSAmator Tuesday, November 27, 2018 11:49 AM
    Tuesday, November 27, 2018 11:27 AM

All replies

  • My recollection is that the error is not raised until the SetInfo method is invoked. I don't believe there is a way to determine which attribute name causes the problem, except to invoke SetInfo separately for each attribute. For example, similar to:

    Try {$result.putex( 2, 'Title' , 'New title' )
        $result.setinfo()}
    Catch {"Error in title"}
    
    Try {$result.putex( 1, 'Deeeeeeeescription' , $null )
        $result.setinfo()}
    Catch {"Error in Deeeeeeeescription"}
    


    Richard Mueller - MVP Enterprise Mobility (Identity and Access)

    • Marked as answer by PSAmator Tuesday, November 27, 2018 11:49 AM
    Tuesday, November 27, 2018 11:27 AM
  • Thank you!
    Tuesday, November 27, 2018 11:49 AM
  • You are welcome.

    Richard Mueller - MVP Enterprise Mobility (Identity and Access)

    Tuesday, November 27, 2018 12:07 PM