I am trying to use COM to access some information from Active Directory.
So far, I have this working to pull information out:
Code:
#include COM.ahk
COM_Init()
; Administrator credentials to bind to the Domain
; Only need if user does not logon as admiistrator
AdminID := "Admin22"
AdminPass := "Password"
; Domain that the information needs to be pulled from.
; Can be an empty string if the computer that this program
; is run from is part of the domain.
DomainString := "domain.com"
; Subdomain that the account is located in.
SubDomainString := "subdomain"
; ID to search for in the domain.
IDString := "smithj"
; Connect to the domain controller
objDSO := COM_GetObject("WinNT:")
; Compose search string
UserSearchString := "WinNT://" . SubDomainString
If (DomainString <> "")
UserSearchString .= "." . DomainString
UserSearchString .= "/" . IDString . ",User"
; Long delay while connecting to this object
objUser := COM_Invoke(objDSO, "OpenDSObject", UserSearchString , AdminID , AdminPass , 3) ; ADS_SECURE_AUTHENTICATION | ADS_USE_ENCRYPTION
; Get account name
FullName := COM_Invoke(objUser, "FullName")
; Check for expired password
If (COM_Invoke(objUser, "Get", "PasswordExpired"))
PasswordExpired := "True"
Else
PasswordExpired := "False"
Rslt := "Full Name: " . FullName . "`n"
Rslt .= "Password Expired: " . PasswordExpired . "`n"
MsgBox , %Rslt%
; Release com objects and close app
COM_Release(objUser)
COM_Release(objDSO)
COM_Term()
ExitApp
There is lots of other information that I can get using this, however I cannot figure out how to get the group information.
In Visual Basic, this should provide a list of the groups but I cannot figure out how to convert it to AutoHotkey:
Code:
; Creates the list of goups the user belongs To
For $objGroup In $objUser.Groups
$Groups = $Groups & $objGroup.Name & ","
Next
The syntax is:
http://msdn.microsoft.com/en-us/library/aa746342(VS.85).aspx
Code:
HRESULT Groups(
[out] IADsMembers **ppGroups
);
I am assuming it translates to something like:
Code:
objGL := COM_Invoke_(objUser, "Groups", "UInt", &*ppGroups)
But how do I read the information?