Sign in to follow this  
Followers 0
Syed23

ADIs member of

6 posts in this topic

Hi Friends,

I was using the _ADIsMemberOf function to find the machine account is belong to specific OU. but i am unable to complete the task. i wonder myself where i am doing the mistake. could someone help me on this?

#include <adfunctions.au3>

$compname = "syed"

$domain_admins_dn = _ADSamAccountNametoFQDN('MYGroup')

$test_user_dn = _ADSamAccountNametoFQDN($compname)

If _ADIsMemberOf($domain_admins_dn, $test_user_dn) Then

MsgBox(64, "", "True")

Else

MsgBox(64, "", "false")

EndIf


Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]

Share this post


Link to post
Share on other sites



If you use my AD UDF (based on John Clellands adfunctions UDF) this can be written like:

#include <ad.aud3>
_AD_Open()
$compname = "syed" & "$" ; note the dollar sign. 
$domain_admins_dn = 'MYGroup'

If _ADIsMemberOf($compname, $domain_admins_dn) Then
    MsgBox(64, "", "True")
Else
   MsgBox(64, "", "false")
EndIf
_AD_Close()

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

If you use my AD UDF (based on John Clellands adfunctions UDF) this can be written like:

#include <ad.aud3>
_AD_Open()
$compname = "syed" & "$" ; note the dollar sign. 
$domain_admins_dn = 'MYGroup'

If _ADIsMemberOf($compname, $domain_admins_dn) Then
    MsgBox(64, "", "True")
Else
   MsgBox(64, "", "false")
EndIf
_AD_Close()

Still it did not work for me :graduated:

Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Let's extend the script a bit so we get some debugging information:

#include <ad.aud3>
_AD_Open()
$compname = "syed" & "$" ; note the dollar sign. 
$domain_admins_dn = 'MYGroup'

$iResult = _AD_IsMemberOf($domain_admins_dn, $compname)
If $iResult = 1 Then
    MsgBox(64, "", "True")
Else
   MsgBox(64, "", "False" & @CRLF & "Error: " & @error)
EndIf
_AD_Close()

It should work now as I've been calling the wrong function!

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

Hi ,

I am sorry. Still it not worked for me. But some how i found the new function and now it's working:). Please suggest me whether am i using the correct one?

#include <AD.au3>

#include <File.au3>

$file = @DesktopDir&"\D.log"

If Not FileExists($file) Then

_FileCreate($file)

EndIf

; Open Connection to the Active Directory

_AD_Open()

$sFQDN = _AD_SamAccountNameToFQDN(@ComputerName & "$")

; Get the Display Name for the computer running this script

$sDisplayName = _AD_FQDNToDisplayname($sFQDN)

If Not @error Then

MsgBox(64, "Active Directory Functions - Example 2", _

"The Fully Qualified Domain Name (FQDN) for this computer is: " & @CRLF & $sFQDN & @CRLF & @CRLF & _

"The Display Name for this computer is: " & @CRLF & $sDisplayName)

_FileWriteLog($file,$sFQDN)

Else

MsgBox(48, "Active Directory Functions - Example 2", _

"The Fully Qualified Domain Name (FQDN) for this computer could not be found: " & @CRLF & $sFQDN & @CRLF & @CRLF & _

"Error / Extended Error: " & @error & " / " & @extended)

EndIf

_AD_Close()


Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]

Share this post


Link to post
Share on other sites

Looks good!

What you don't need is the call to _AD_SamAccountNameToFQDN(). All functions now accept SamAccountName and FQDN as parameters.


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  
Followers 0