Jump to content
Sign in to follow this  
Ghost21

Active Directory Query

Recommended Posts

Ghost21

When I do something like this

Const $ADS_NAME_INITTYPE_GC = 3

Const $ADS_NAME_TYPE_NT4 = 3

Const $ADS_NAME_TYPE_1779 = 1

If @error Then Exit

$oMyError = ObjEvent("AutoIt.Error", "ComError")

$objRootDSE = ObjGet("LDAP://RootDSE")

If @error Then

Else

$objTrans = ObjCreate("NameTranslate")

$objTrans.Init($ADS_NAME_INITTYPE_GC, "")

$objTrans.Set($ADS_NAME_TYPE_1779, @LogonDomain)

$objTrans.Set($ADS_NAME_TYPE_NT4, @LogonDomain & "\" & $User)

$strUserDN = $objTrans.Get($ADS_NAME_TYPE_1779)

$UserObj = ObjGet("LDAP://" & $strUserDN)

I keep getting a error message show up

The requested action with this object has failed.:

$objTrans.Set($ADS_NAME_TYPE_1779, @LogonDomain)

$objTrans.Set($ADS_NAME_TYPE_1779, @LogonDomain)^ ERROR

I have put in error trapping but it still seems to quit ....

Is it a networking issue ?

Share this post


Link to post
Share on other sites
PsaltyDS

RFC 1779 names look like "dc=MySubDomain,dc=MyDomain,dc=com", and I don't think that's what you get from @LogonDomain (it gives you the NetBIOS name). If you're going to use that, use $ADS_NAME_TYPE_NT4 for the type.

:idea:

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
water

When I do something like this

Const $ADS_NAME_INITTYPE_GC = 3
Const $ADS_NAME_TYPE_NT4 = 3
Const $ADS_NAME_TYPE_1779 = 1
If @error Then Exit
$oMyError = ObjEvent("AutoIt.Error", "ComError")
$objRootDSE = ObjGet("LDAP://RootDSE")
If @error Then
 Else
    $objTrans = ObjCreate("NameTranslate")
    $objTrans.Init($ADS_NAME_INITTYPE_GC, "")
    $objTrans.Set($ADS_NAME_TYPE_1779, @LogonDomain)
    $objTrans.Set($ADS_NAME_TYPE_NT4, @LogonDomain & "\" & $User)
    $strUserDN = $objTrans.Get($ADS_NAME_TYPE_1779)
    $UserObj = ObjGet("LDAP://" & $strUserDN)
I keep getting a error message ...

What are you trying to do? You know there is an Active Directory UDF available? For download please see my signature. If there is a function missing I will be glad to incorporate it into the UDF. Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.