Syed23 Posted November 19, 2010 Share Posted November 19, 2010 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] Link to comment Share on other sites More sharing options...
water Posted November 19, 2010 Share Posted November 19, 2010 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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Syed23 Posted November 19, 2010 Author Share Posted November 19, 2010 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 Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font] Link to comment Share on other sites More sharing options...
water Posted November 20, 2010 Share Posted November 20, 2010 (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 November 20, 2010 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 - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Syed23 Posted November 23, 2010 Author Share Posted November 23, 2010 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] Link to comment Share on other sites More sharing options...
water Posted November 23, 2010 Share Posted November 23, 2010 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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now