Page 1 of 1 1
Topic Options
#87056 - 2002-07-27 04:18 AM TranslateName() - Microsoft API bug
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
JensKalski ,I have read the BUG: Error 80072116 When You Use the Set Method of the NameTranslate API link you posted in the UDF thread. I can't fix a Microsoft bug. What is your specific problem. How are you using the the TranslateName() UDF? How are you being affected by the bug?

[ 27 July 2002, 14:44: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#87057 - 2002-07-27 09:08 AM Re: TranslateName() - Microsoft API bug
JensKalski Offline
Starting to like KiXtart

Registered: 2000-12-13
Posts: 186
Loc: Germany
I have had problems to translate into a LDAP-path. Then I have tried to reproduce the problems with a little vbscript-program. And I get exactly the same error-messages as described in the kb-article.
_________________________
Jens Kalski

Top
#87058 - 2002-07-27 02:52 PM Re: TranslateName() - Microsoft API bug
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Well that sounds like you have confirmed the Microsoft bug.

I have not had any problems myself. Can you avoid having the problem characters in your object names? Can you give me an example of your data and usage that fail?
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#87059 - 2002-07-27 07:22 PM Re: TranslateName() - Microsoft API bug
JensKalski Offline
Starting to like KiXtart

Registered: 2000-12-13
Posts: 186
Loc: Germany
[Big Grin] Oh man, I have found MY error!!!

"Simply" I want to set the computerdescription with data that I get from an inventorydatabase. From that database I can only get the workstationname but not the complete LDAP-path (including its position in our OU-structure). Maybe I'm thinking to complicated. But I think I must first translate my information like \ in a LDAP-path to connect to the object when I want to set the description in the active directory.

I have tried it with a code-snippet in vbscript like this
code:
Set NameTranslate = CreateObject("NameTranslate")
NameTranslate.Init 1, "domain"
NameTranslate.Set 4, "workstation"
ReturnName = NameTranslate.Get(1)
WScript.Echo ReturnName

I have simply forgotten the $ at the end of the workstationname. [Wink]
_________________________
Jens Kalski

Top
#87060 - 2002-07-27 07:51 PM Re: TranslateName() - Microsoft API bug
JensKalski Offline
Starting to like KiXtart

Registered: 2000-12-13
Posts: 186
Loc: Germany
Now I'm really and absolutely confused. It functions with some workstation-accounts and with some others it does not.

Is there an easier way to set the computerdescription in the active directory?
_________________________
Jens Kalski

Top
#87061 - 2002-07-27 08:42 PM Re: TranslateName() - Microsoft API bug
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Please take a look at the code below. It successfully returns the DN for my computer and sets the description.

Please post your code so that we can take a look at why you are having problems. Based on what you stated. I would expect that either your database contains incorrect names or names that no longer exist in your domain. Have you checked the error codes when you do not get the results that you expected?
code:
$DN = TranslateName (3, "", 3, "@Domain\@wksta$$", 1)
? "DN = " + $DN[0]
? "Error = " + $DN[1]
? "ErrorText = " + $DN[2]

$obj = GetObject("LDAP://@domain/" + $DN[0])

? "GetObject: @error @Serror"


; Enumerate ALL properties
; Uncomment to show all properties
;EnumObjProps($obj)

? "Computer Description:" + $obj.description
$obj.description = "DSS Laptop"
$obj.SetInfo

Function EnumObjProps($object)
Dim $Class, $Schema, $Value, $property, $cont

$Class = GetObject($object.schema)
? "Class: " + $Class.Name
? "GUID: " + $Class.GUID
? "Implemented by: " + $Class.CLSID

If $Class.Container
? ? "Container Object"
? "Class Contains:"
For Each $cont In $Class.Containment
? " " + $cont
Next
Else
? ? "Leaf Object"
EndIf

? "Mandatory Properties in this Class: "
For Each $property In $Class.MandatoryProperties
? " " + $property
Next

? ? "Optional Properties in this Class: "
For Each $property In $Class.OptionalProperties
? " " + $property
Next
EndFunction


Function TranslateName ($InitType, $BindName, $LookupNameType, $LookupName, $ReturnNameType)

Dim $InitType, $BindName, $LookupNameType, $LookupName, $ReturnNameType
Dim $NameTranslate, $ReturnName, $Error, $ErrorText

$Error = 0
$ErrorText = ""
$ReturnName = ""
$NameTranslate = CREATEOBJECT ("NameTranslate")
$Error = @error
$ErrorText = @serror
if $Error = 0
$NameTranslate.Init ($InitType, $BindName)
$Error = @error
$ErrorText = @serror
if $Error = 0
$NameTranslate.Set ($LookupNameType, $LookupName)
$Error = @error
$ErrorText = @serror
if $Error = 0
$ReturnName = $NameTranslate.Get($ReturnNameType)
$Error = @error
$ErrorText = @serror
endif
endif
endif
$TranslateName = $ReturnName, $Error, $ErrorText
Endfunction

_________________________
Home page: http://www.kixhelp.com/hb/

Top
#87062 - 2002-07-28 05:50 AM Re: TranslateName() - Microsoft API bug
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
Howard,

Nice looking piece of code... Can't try it out right now, but I can't wait to try it out on Monday when I get back to work.

I hope it works as well as it looks. [Big Grin]

Top
#87063 - 2002-07-28 06:25 PM Re: TranslateName() - Microsoft API bug
JensKalski Offline
Starting to like KiXtart

Registered: 2000-12-13
Posts: 186
Loc: Germany
I will also try it out tomorrow at work.
_________________________
Jens Kalski

Top
#87064 - 2002-07-28 06:27 PM Re: TranslateName() - Microsoft API bug
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
mmm...
what are you ppl?
don't you work on weekends at all?
_________________________
!

download KiXnet

Top
#87065 - 2002-07-28 06:58 PM Re: TranslateName() - Microsoft API bug
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Im with yeah buddy ! These people that don't work on the weekend - jeesh ! [Wink]
Top
#87066 - 2002-07-28 07:11 PM Re: TranslateName() - Microsoft API bug
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
This is real bummer. The weekend is the the only time when I can really help out. You add code, offer help, and then wait to respond. And wait, and wait, and wait. [Frown] Then on Monday, you're boss wants you to do his work and not the rest of the world's.

[ 28 July 2002, 19:12: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#87067 - 2002-07-28 11:51 PM Re: TranslateName() - Microsoft API bug
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
well, say your boss you don't need him [Razz]
let him go and ask not to remember you as bad.
say you love him but it's time for you to move on...

have you tried that?
after those lines, he will let you do whatever you want [Big Grin]
_________________________
!

download KiXnet

Top
#87068 - 2002-07-29 10:00 AM Re: TranslateName() - Microsoft API bug
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
I have too many bosses. I have one that pays my weekly paycheck, and one that pays other dividends. [Wink]

I work from 08:00 to 03:00 almost 7 days a week right now. I'M TIRED Work for the mouse during the day and then work doing house remodeling till the wee hours of the morning. Don't have time for coding much right now. [Frown]

Top
#87069 - 2002-07-29 11:33 AM Re: TranslateName() - Microsoft API bug
JensKalski Offline
Starting to like KiXtart

Registered: 2000-12-13
Posts: 186
Loc: Germany
Thanks for the code Howard. I have tested it at work and found that it works. I don't know, what mistakes I have made. I will code my script based on your script.
_________________________
Jens Kalski

Top
#87070 - 2002-07-29 01:49 PM Re: TranslateName() - Microsoft API bug
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Jens, glad to hear that your problems seem to be behind you now.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#87071 - 2002-07-30 02:14 AM Re: TranslateName() - Microsoft API bug
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
Pretty SLICK Howard.

Code worked well for me. Thanks for posting.

Top
#87072 - 2002-07-30 03:26 AM Re: TranslateName() - Microsoft API bug
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Hey DOC, you can find some documentation for the TranslateName UDF in the UDF Library.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#87073 - 2002-07-30 03:40 AM Re: TranslateName() - Microsoft API bug
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
Yeah.. I saw it earlier.

So.. which is newer code? Here or the UDF, or both are same code now?

Top
#87074 - 2002-07-30 04:00 AM Re: TranslateName() - Microsoft API bug
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
The TranslateName function is the same code in the UDF library. The EnumObjProps was never posted in the Library.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 640 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.096 seconds in which 0.025 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org