Jump to content
Sign in to follow this  

_AD_GetObjectAttribute gives unexpected result

Recommended Posts



I'm trying to get email from AD with _AD_GetObjectAttribute.

the following script gives back email adress for given sAMAccountName:

#include <AD.au3>
Global $aProperties
If @error Then Exit MsgBox(16, "Active Directory Example Skript", "Function _AD_Open encountered a problem. @error = " & @error & ", @extended = " & @extended)
$aProperties = _AD_GetObjectAttribute("anysAMAccountName", "mail")

Tried many sAMAccountName's it works good, but on one Name 'XiaopenL' result is:


This is not the mail adress. Is it a failure of the AD-server?

Edited by Nogo

Share this post

Link to post
Share on other sites

Please a look at this site. It describes attributee mail and proxyAddresses.

Could you get the values of attribute "proxyAddresses"? Be aware that it is a multivalue attribute and hence _AD_GetObjectAttribute returns an array.

My UDFs and Tutorials:


Active Directory (2018-06-01 - Version - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki

ADO - Wiki


Share this post

Link to post
Share on other sites

Could you get the values of attribute "proxyAddresses"?

No it is not set.

But I've downloaded 'Active Directory Explorer'. -> The mail adress of sAMAccountName "XiaopenL" is set to


So everything is working ok. The Database is not tended right.

I didn't expected that this is the failure.

Many thanks for your help and for the link.

Edited by Nogo

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  

  • Similar Content

    • tweakster2010
      By tweakster2010
      Hello All,
      It has been a long time since I posted, role changes etc involving work and I finally am back to modifying a program I write in AutoIt that has AD integration. I am at a point where we are modifying our structure where I am validating users access via what Distribution List they belong to in our AD OU's. What I have run into is the OU is a sub OU of a sub OU now. Meaning: CN=team, OU=DL, OU=Groups, DC=business.com(working), is now CN=Team, OU=SubDL, OU=DL, OU=Groups, DC=business.com (Not working).  Just curious if the AD functionality should be able to read it or maybe I am missing something?
      ElseIf _AD_IsMemberOf("CN=Team,OU=Distribution Lists,OU=Groups,DC=business,DC=com", $sFQDN_User) Then #works for primary Distro ElseIf _AD_IsMemberOf("CN=Team,OU=SubDL,OU=Distribution Lists,OU=Groups,DC=business,DC=com", $sFQDN_User) Then #fails for subOU of DL How I am accessing AD to get the information:
      _AD_Open() Global $aUser = _AD_GetObjectsInOU("", "(&(objectCategory=person)(objectClass=user)(samaccountname=" & @UserName & "))", 2, "ADsPath,Displayname,distinguishedName") Global $sDisplayName0 = $aUser[1][1] ; Displayname ;MsgBox(0,"", $sDisplayName0) If StringLeft($sDisplayName0, 2) = "9-" Then $Displaynamestring = StringTrimLeft($sDisplayName0, 2) $Displaynamestring1 = StringTrimRight($Displaynamestring, 6) The error code generated is a 1 with a 0 extended. I assume it is because it cannot find the SubOU.
      Thanks for any assistance.
    • antmar904
      By antmar904
      I'm trying to read all cells used in column "C" in excel to an array but not sure how.
      Local $NameArray = _Excel_RangeRead($oWorkbook, $oWorkbook.Activesheet, $oWorkbook.Range["C"].End)  
    • water
      By water
      Extensive library to control and manipulate Microsoft Active Directory.

      Threads: Development - General Help & Support - Example Scripts - Wiki
      Previous downloads: 30467
      Known Bugs: (last changed: 2018-08-08)
      _AD_IsPasswordExired: It compares the expiration time (UTC - but should be local time) with the current time (local time). Which is 2 hours off here. Will be fixed in the next version.
      Or replace line If $aTemp[11] <= _NowCalc() Then Return 1 with
      If $aTemp[9] <= _NowCalc() Then Return 1  
      Things to come: (last changed: 2018-08-08)
      Internal function to convert Large Integer to Date String. _AD_ModifyAttribute fully supports single-value and multi-value attributes. Returns better error information. Better support for Fine Grained Password Policy
      BTW: If you like this UDF please click the "I like this" button. This tells me where to next put my development effort
    • Blois
      By Blois
      Hey Guys,
      I'm ned help to consult in other domain. My three domain contains any domains.
      How do I get this query done?
      Tks for the Help!