Jump to content

Active Directory UDF


water
 Share

Recommended Posts

Seems like exchange didn't like me just modifying the exchange attribute for the proxyAddresses Attribute. I need to remove the attributes now and then added them. Its quite depressing, but I think I am going to be doing this manually :-) I'm sure there is a away to powershell this, but I'm a little weak with Powershell andby the time I figure it out I will probably mostly have been able to do this manually. Live and learnĀ 

Link to comment
Share on other sites

Actually thinking about this, what I did was use the update feature in the Modify Attribute command.

So this all started because there were some old legacy addresses in the proxyAddresses attribute. I got all this information into an array and remove the legacy addresses from the array. I then used the update option of Modify attribute to add only the ones I had left in the array. if I had just deleted the addresses that I didn't want using the modify attribute and not use Update I probably would have been ok.

Darn it!

Well, I'm not going to worry about this now, but I certainly have learned a lesson on this! :-)

Link to comment
Share on other sites

Is there anything you would like to be changed to enhance the UDF?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

To add addresses you still can use _AD_ObjectModify. To set the primary SMTP address (the sender address) there is a function in the UDF (I'm on vacation right now so don't know the exact name).

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

The name of this function is: _AD_AddEmailAddress

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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,

is it possible to use the _AD_ObjectExists function to find a user with only the beginning of the name or other, and to have the results in a array
Ā 

ex : search user , "Marley bob" ou "Marley Paul" , with only "marley" and have the result in a array.

thank you for your help

Edited by ludoo
Link to comment
Share on other sites

No: _AD_ObjectExists needs the exact SamAccountName or FQDN. The function only checks for a single object.

But you could use function _AD_GetObjectsInOU. The example script and the description in the UDF tell you how to use (Wildcards or ANR).

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

Can you please post how you use _AD_GetObjectsInOU?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

Hello Guys,

Im new to the forum but have problems and could yous a quick help

I use the function _AD_IsMemberOf

My domain hierarchy is like

Test-domain

childdomain1 and childdomain2

I created a triangle two-way relationship model, tested well.

I have a universal group in the parent domain with which contiains subordinated groups from the child domains. I will make sure that regardless from the domain membership of the pc and the curent user I can allways check the membership status of the current user in the parent group or in all subordinated groups (I use the default depth=10)

Is this possible with this function?

Until now I only get positiv boolean exit codes, if I test with a user from the parent domain, who is member in the parent domain group

I could use some quick support.

thank you

S

Link to comment
Share on other sites

Welcome to AutoIt and the forum!

I assume you are using the latest version of the AD UDF (1.4.1.1 for AutoIt > 3.3.1Ɵ.2)?

Can you please post the full statement you use to check group membership?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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,

yes all actual, I frequently check the site for updates.

Func User_Auth()

    $ADOPEN=_AD_Open($LDMS_USER, $LDMS_PASSWORD, $DOMDNSDomain, $DOMDCServer, $DOMDomainConfig, $DOMSecurity)
;~     MsgBox(0,'ADOPEN','$ADOPEN: '&$ADOPEN&@CRLF&'@error: '&@error)

    $ISMEMBER=_AD_IsMemberOf($DOMGroup, $DOMObject, $bIncludePrimaryGroup, $bRecursive, $iDepth)
;~     MsgBox(0,'ADOPEN','$ISMEMBER: '&$ISMEMBER&@CRLF&'@error: '&@error)

    Switch $ISMEMBER
        case '0'
;~             MsgBox(16,'Security','ERROR')
            GUI_BLOCK()
        Case '1'
;~             MsgBox(64,'Security','DONE')
            GUI_ENABLE()

    EndSwitch

_AD_Close()

EndFunc
Link to comment
Share on other sites

hi ,

Here are the features that I use:

the first function to create the user : newuser

Func newuser($nom,$prenom)

    ; mise en format prĆ©nom et nom pour le traitement
        $nom = StringReplace($nUser," ","");supprime espace vide
        $long = StringLen($nom)
        If $long > 16 Then $nom = StringMid($nom,1,16);16 caracteres maxi
        $nom = StringUpper($nom)
        $prenom = StringReplace($pUser," ","");supprime espace vide
        $prenom = StringMid($prenom,1,2);2 caracteres
        $prenom = StringUpper($prenom)

        Global $spUser = StringLeft($pUser, 2) ; rĆ©cupere les 2 premiere lettre du prĆ©nom
        Global $spUserPr = StringLeft($pUser, 1) ;rĆ©cupere la premiere lettre du prĆ©nom
        Global $spUserL = StringLower($pUser) ; pour mettre le prĆ©nom en minuscule
        Global $snUserL = StringLower($nom) ; pour mettre le nom en minuscule
        Global $snUserU = StringUpper($nUser) ; pour mettre le nom en majuscule
;~      Global $spUserU = StringUpper($spUser) ; pour mettre le prĆ©nom en majuscule
        Global $spUserUPr = StringUpper($spUserPr) ; pour mettre la premiere lette du prĆ©nom en majuscule
        Global $sStringpUsers = StringTrimLeft($pUser, 1) ; pour enlever la premiere lettre du prĆ©nom Ć  partir de la gauche
        Global $sStringpUsersL = StringLower($sStringpUsers) ; mettre le prĆ©nom en minuscule sans la premiere lettre
        Global $sAMAccountNameUser = $nom&$prenom ; association du nom en majuscule + les 2 premiere lettre du prĆ©nom en majuscule
        Global $suserPrincipalName = $spUserL&"."&$snUserL&$suffixeUPN ; association du prenom en minuscule + le nom en minuscule + suffixe UPN
        Global $cnUser = $snUserU&' '&$spUserUPr&$sStringpUsersL ; association du nom en majuscule + premiere lettre prenom en majuscule + reste du prĆ©nom en minuscule
        Global $email = $spUserL&"."&$snUserL&$suffixemail
        Global $nomuser = $nom
        getalluser()
EndFunc ; => newuser

the second feature to look for another user with the same name : getalluser

Func getalluser()
    _AD_Open()
    ConsoleWrite($sAMAccountNameUser &@CRLF) ; compte d'ouverture de session 2000
    Sleep(5000)
;~  Global $getalluser = $sAMAccountNameUser
    Global $getalluser = $nomuser
    ConsoleWrite($getalluser &@CRLF)
    Sleep(5000)
    Global $TargetOUuser = "OU=xx,OU=xx,OU=xx,OU=xx,DC=xx,DC=xx"
    Global $aObjects[1][1]


        $aObjects = _AD_GetObjectsInOU($TargetOUuser, "(&(objectcategory=person)(objectclass=user)(cn=" & $getalluser & "*))", 2, "sAMAccountName")
        If @error > 0 Then
            MsgBox(64, "Active Directory Functions - Example 2", "No OUs could be found")
        Else
            _ArrayDisplay($aObjects, "Active Directory Functions - Example 2  - Objects in OU '" & $TargetOUuser & "'")
        EndIf
EndFunc

the third function for a single user : userunic()

Func userunic()
    If _AD_ObjectExists($nom & $prenom) Then
        Local $array[6] = [$sAMAccountNameUser,$nomUnic1,$nomUnic2,$nomUnic3,$nomUnic4,$nomUnic5,$nomUnic6]
        For $i = 65 To 90 ;ASCII Character A Ć  Z
            Local $array[2] = [$sAMAccountNameUser,Chr($i)]
            _ArraySearch($array,$sAMAccountNameUser & Chr($i))
            _ArraySearch($array,$nom & $prenom & Chr($i))
                If @error Then
                    $nomUnic_1 = $nom & $prenom $ Chr($i)
                    Global $suserPrincipalName = $spUserL&"."&$snUserL&"."&Chr($i)&$suffixeUPN
                    Global $cnUser = $snUserU&' '&$spUserUPr&$sStringpUsersL&Chr($i)
                    Global $email = $spUserL&"."&$snUserL&"."&Chr($i)&$suffixemail
                    ExitLoop
                EndIf
        Next
        ConsoleWrite($nomUnic1 & @CR)
        ConsoleWrite($suserPrincipalName & @CR)
        ConsoleWrite($cnUser & @CR)
        Return $nomUnic_1

    Else
        $sAMAccountNameUser = $sAMAccountNameUser
    EndIf
EndFunc ;=> userunic

how to put the result the second feature in the array the third function

Link to comment
Share on other sites

thank you for your tip

I have a forrest with neer to 25-50 child domains, and around 25K - 30K End Users, if possible I would mind to create an array with so many records, I really want to focus on the built in function _AD_IsMemberOf. If its not possible, I have to move to powershell.

but thanx again.

Link to comment
Share on other sites

Hi,

yes all actual, I frequently check the site for updates.

Func User_Auth()
    $ADOPEN=_AD_Open($LDMS_USER, $LDMS_PASSWORD, $DOMDNSDomain, $DOMDCServer, $DOMDomainConfig, $DOMSecurity)
    $ISMEMBER=_AD_IsMemberOf($DOMGroup, $DOMObject, $bIncludePrimaryGroup, $bRecursive, $iDepth)
    Switch $ISMEMBER
        case '0'
            GUI_BLOCK()
        Case '1'
            GUI_ENABLE()
    EndSwitch
_AD_Close()
EndFunc

SciteWalker,

what you try to do should be possible with function _AD_IsMemberOf.

What are the values for parameters $bIncludePrimaryGroup, $bRecursive and $iDepth?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  $bIncludePrimaryGroup=True
Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  $bRecursive=True
Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  $iDepth=10

Link to comment
Share on other sites

As there has been a bug in the last version regarding $bIncludePrimaryGroup could you please try with

$bIncludePrimaryGroup=False

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

You mean you want to extend the AD structure to support NIS?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

×
×
  • Create New...