Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - 80005000 Error trap

Reply
 
Old 02-20-2009   #1 (permalink)
Dave Susemiehl


 
 

80005000 Error trap

Hi, I can muddle through scripting ok most of the time but I'm not sure how
to handle this.

So here's my dilemma, I want to use a text file for the OU's and Groups to
create in the OU's. I read them into an array ok so I have them available
but obviously each OU contains multiple groups. If I just cycle through the
Array Creating the OU's I will quickly run into an already exists error. I
couldn't find a good way to do an if exists on OU's so I decided to try to
get the OU and if it errors the script would create the ou. The nice simple
GET line looks something like this:

Set mkOU = GetObject("LDAP://OU=" & arrOU(0) & ",OU=parentOU," & DomainPath)
---This line gets the desired results

And then do an error trap so that if the 80005000 error is encounter It
creates the OU.

Any help would be appreciated.



My System SpecsSystem Spec
Old 02-20-2009   #2 (permalink)
Richard Mueller [MVP]


 
 

Re: 80005000 Error trap


"Dave Susemiehl" <Dave Susemiehl@xxxxxx> wrote in message
news:1F154E09-C841-43D7-A182-D17A802B050B@xxxxxx
Quote:

> Hi, I can muddle through scripting ok most of the time but I'm not sure
> how
> to handle this.
>
> So here's my dilemma, I want to use a text file for the OU's and Groups to
> create in the OU's. I read them into an array ok so I have them available
> but obviously each OU contains multiple groups. If I just cycle through
> the
> Array Creating the OU's I will quickly run into an already exists error.
> I
> couldn't find a good way to do an if exists on OU's so I decided to try to
> get the OU and if it errors the script would create the ou. The nice
> simple
> GET line looks something like this:
>
> Set mkOU = GetObject("LDAP://OU=" & arrOU(0) & ",OU=parentOU," &
> DomainPath)
> ---This line gets the desired results
>
> And then do an error trap so that if the 80005000 error is encounter It
> creates the OU.
>
> Any help would be appreciated.
>
Use "On Error Resume Next" to suppress normal error handling (which aborts
the script). Then you can test the Err object for error number and
description. Use "On Error GoTo 0" to restore normal error handling (this
also clears the Err object). For example:
========
On Error Resume Next
Set mkOU = GetObject("LDAP://ou=" arrOU(0) & ",ou=parentOU," & DomainPath)
If (Err.Number <> 0) Then
' Error raised attempting to bind the OU.
' Display error information (optional).
Wscript.Echo "Error binding to OU " & arrOU(0)
Wscript.Echo "Error Number: " & Err.Number
Wscript.Echo "Description: " & Err.Description
Wscript.Echo "Source: " & Err.Source
On Error GoTo 0
' Create the OU.
' ...
Else
On Error GoTo 0
' The OU must already exist
End If
=========
If you know the specific error number you want to trap, you can test for
that. However, Err.Number will be decimal, while 80005000 is hex, so you
will need to convert. Best to test and see what Err.Number returns (some are
negative). I find Err.Number is -2147016656 when I attempt to bind to a
non-existent OU. If I have an invalid character (invald DN format) I
get -2147016654. Might be best just to test if Err.Number is non-zero.

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Trap an Error from an EXE PowerShell
Ping error trap? PowerShell
why cannot Trap catch error PowerShell
Script Error: 0x80005000, Code: 80005000, Source: (null) VB Script
How to trap this error in PowerShell PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46