Jump to content

Active Directory UDF - Help & Support


water
 Share

Recommended Posts

Can you post the distinguished name of such an item?

I will do one better,

here is the output of the script,

I have blurred/covered some users names and such, as I dont think my company would like me posting user names on the interwebs.

Haha, as always, thanks!

Link to comment
Share on other sites

Thanks for the screenshot!

If you run example script _AD_GetObjectProperties.au3 you will see all properties for the current user (Example 1). In my case I get

[130]|objectCategory|CN=Person,CN=Schema,CN=Configuration,DC=egv,DC=at
[131]|objectClass|organizationalPerson
[132]|objectClass|user
[133]|objectClass|person
[134]|objectClass|top
for objectCategory and ObjectClass.

Could you please run _AD_GetObjectProperties for one of the distinguished names in your screenshot and post what you get for ObjectClass and ObjectCategory.

If you like, you can delete the screenshot now.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Thanks for the screenshot!

If you run example script _AD_GetObjectProperties.au3 you will see all properties for the current user (Example 1). In my case I get

[130]|objectCategory|CN=Person,CN=Schema,CN=Configuration,DC=egv,DC=at
[131]|objectClass|organizationalPerson
[132]|objectClass|user
[133]|objectClass|person
[134]|objectClass|top
for objectCategory and ObjectClass.

Could you please run _AD_GetObjectProperties for one of the distinguished names in your screenshot and post what you get for ObjectClass and ObjectCategory.

If you like, you can delete the screenshot now.

Sure here are the results

For an entry WITH a user name gives me

Objectclass:

Person

user

organizationalPerson

top

objectCategory CN=Person,CN=Schema,CN=Configuration,DC=XXXXXXX,DC=org

For one of the entries Without a username:

objectclass:

top

msExchActiveSyncDevice

Object Category

CN=ms-Exch-Active-Sync-Device,CN=Schema,CN=Configuration,DC=XXXXXXX,DC=org

Edited by ICANSEEYOU7687
Link to comment
Share on other sites

If you run

#include <ad.au3>
_AD_Open()
$aResult = _AD_GetObjectsInOU("", "(&(objectcategory=person)(objectclass=user))", 2, "sAMAccountName,distinguishedName,displayname")
_ArrayDisplay($aResult)
you shouldn't get any of those active-sync etc. entries because their objectcategory and objectclass is different.

Could you please test?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

I did, same result, using

$aObjects = _AD_GetObjectsInOU($sOU, "(name=*)", 2, "sAMAccountName,distinguishedName,displayname")
If @error > 0 Then
    MsgBox(64, "Active Directory Functions - Example 1", "No OUs could be found")
Else
    _ArrayDisplay($aObjects, "Active Directory Functions - Example 1 - Objects in OU '" & $sOU & "'")
    $iResult = _AD_GetObjectsInOU($sOU, "(&(objectcategory=person)(objectclass=user))", 2, "sAMAccountName,distinguishedName,displayname", "displayname", True)
    MsgBox(64, "Active Directory Functions - Example 1", "This example returned " & $iResult & " records")
EndIf
_AD_Close()

Strange, the ones that are not classified as a person, or a user still show up.

Link to comment
Share on other sites

Is there a difference in the number of records if you run this two commands?

#include <ad.au3>
_AD_Open()
$sOU = ""
$aResult = _AD_GetObjectsInOU($sOU, "(&(objectcategory=person)(objectclass=user))", 2, "sAMAccountName,distinguishedName,displayname")
_ArrayDisplay($aResult)
$iResult = _AD_GetObjectsInOU($sOU, "(&(objectcategory=person)(objectclass=user))", 2, "sAMAccountName,distinguishedName,displayname", "", True)
Msgbox(0,"","Number of records: " & $iResult)
_AD_Close()

What version of the AD UDF do you run - please check the ; UDF Version ...: 1.0.0 line in AD.au3.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Is there a difference in the number of records if you run this two commands?

#include <ad.au3>
_AD_Open()
$sOU = ""
$aResult = _AD_GetObjectsInOU($sOU, "(&(objectcategory=person)(objectclass=user))", 2, "sAMAccountName,distinguishedName,displayname")
_ArrayDisplay($aResult)
$iResult = _AD_GetObjectsInOU($sOU, "(&(objectcategory=person)(objectclass=user))", 2, "sAMAccountName,distinguishedName,displayname", "", True)
Msgbox(0,"","Number of records: " & $iResult)
_AD_Close()

What version of the AD UDF do you run - please check the ; UDF Version ...: 1.0.0 line in AD.au3.

Its the latest version 1.0.0

Link to comment
Share on other sites

What are the results if you run the above script? Could you please post the number of records? We once had a problem when the user had a lot of records.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

What are the results if you run the above script? Could you please post the number of records? We once had a problem when the user had a lot of records.

When I close the window the results say 52, and I do have 52 users with actual account names. But the list contains 147 items, with the accuonts with no account names

Link to comment
Share on other sites

I have no idea what the problem might be. I tested here and the result is just fine.

Could you please run this modified script? I now display the objectclass and the name in the array. All records should have objectclass "user".

Row 0, Col 0 should be 52 (= the number of users). The msgbox then should display 52 as well.

#include <ad.au3>
_AD_Open()
$sOU = ""
$aResult = _AD_GetObjectsInOU($sOU, "(&(objectcategory=person)(objectclass=user)(name=*))", 2, "sAMAccountName,objectclass,name")
_ArrayDisplay($aResult)
$iResult = _AD_GetObjectsInOU($sOU, "(&(objectcategory=person)(objectclass=user)(name=*))", 2, "sAmaccountName", "", True)
Msgbox(0,"","Number of records: " & $iResult)
_AD_Close()
Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

I have no idea what the problem might be. I tested here and the result is just fine.

Could you please run this modified script? I now display the objectclass and the name in the array. All records should have objectclass "user".

Row 0, Col 0 should be 52 (= the number of users). The msgbox then should display 52 as well.

#include <ad.au3>
_AD_Open()
$sOU = ""
$aResult = _AD_GetObjectsInOU($sOU, "(&(objectcategory=person)(objectclass=user)(name=*))", 2, "sAMAccountName,objectclass,name")
_ArrayDisplay($aResult)
$iResult = _AD_GetObjectsInOU($sOU, "(&(objectcategory=person)(objectclass=user)(name=*))", 2, "sAmaccountName", "", True)
Msgbox(0,"","Number of records: " & $iResult)
_AD_Close()

That worked!

The strange accounts listed must have had some weird classifications to them... There are in fact 52 entries in the table. Thanks, for all of the followups! Now I gotta read up on exporting this table to a .txt document. Thanks!

Link to comment
Share on other sites

Glad it works now!

Now I gotta read up on exporting this table to a .txt document.

_FileWriteFromArray (unfortunately only works for one-dimensional arrays)

Edit: A function to write 2D-Arrays can be found

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Glad it works now!

_FileWriteFromArray (unfortunately only works for one-dimensional arrays)

Edit: A function to write 2D-Arrays

I was just about to make a post in general help about that. The 2D array worked perfectly, thanks very much! Extremely helpful as usual!

Link to comment
Share on other sites

:)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Hallo Water

I have a Problem with the Function _AD_CreateGroup. I don't know how to use the Parameter "$iAD_Type". I would like to create a LOCAL Group and and not know how to use the variable. What means "Global security must be 'BitOr'ed with a scope."? The explanation of BitOr use only numbers.

Thank you for your help.

Greets

Turi

Link to comment
Share on other sites

Hi Turi,

The default value for $iAD_Type is $ADS_GROUP_TYPE_GLOBAL_SECURITY which is defined as "BitOR($ADS_GROUP_TYPE_GLOBAL_GROUP, $ADS_GROUP_TYPE_SECURITY_ENABLED)".

Maybe the ADS_Group_Type_Enum Enumeration gives you some more information.

I'm not very familiar with the different group types. I've left this function of the original author (John Clelland) nearly untouched.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Thank you for the help.

Now i understand my Problem. In your AD.au3 are some Global Const like: Global Const $ADS_GROUP_TYPE_GLOBAL_GROUP = 0x2. But 2 are missing.

Global Const $ADS_GROUP_TYPE_DOMAIN_LOCAL_GROUP = 0x4

Global Const $ADS_GROUP_TYPE_LOCAL_SECURITY = BitOR($ADS_GROUP_TYPE_DOMAIN_LOCAL_GROUP, $ADS_GROUP_TYPE_SECURITY_ENABLED)

It would be nice, if in the next version of the AD.au3 they would be.

Greets

Edited by turi
Link to comment
Share on other sites

I will include them in the next version.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Hi water,

how can I retrieve a user or group name from a SID?

I'm looking for something like '_AD_SIDToSamAccountName()'...

Greets,

-supersonic.

Edit:

I've found this solution:

Local $aResult = _AD_GetObjectsInOU("", "(&(objectSid=" & $aST_Text[$i] & "))", 2, "samAccountName", "", False)
ConsoleWrite($aResult[1] & @CRLF)

Is there a more simple way without array?

Edited by supersonic
Link to comment
Share on other sites

Hi supersonic,

haven't used it myself but maybe function "_Security__LookupAccountSid" does what you need? This function is part of the AutoIt package - Security Management UDF

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...