Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Get OU (Organizational Unit) name that a local computer belongs to using C++

78 views
Skip to first unread message

nki00

unread,
Jan 24, 2012, 8:01:14 PM1/24/12
to
I need to find out the name of the OU that the local computer (that is
connected to the Active Directory) belongs to using WinAPI/C++. Any ideas?


Stefan Kuhr

unread,
Feb 3, 2012, 3:29:12 AM2/3/12
to
Hello nki00,

On 1/25/2012 2:01 AM, nki00 wrote:
> I need to find out the name of the OU that the local computer (that is
> connected to the Active Directory) belongs to using WinAPI/C++. Any ideas?
>
>

I would assume that you could just append the $ to the computer name and
lookup its computer SID (so you look up the SID of the computer account
in AD). Then, assuming it is a Windows Server 2003 domain, you can look
up the object using an LDAP query of the form
LDAP://servername/<SID=XXXXX> or with serverless binding such as this:
LDAP://<SID=XXXXX>. You should then be able to query the
distinguishedName attribute of this object which contains the OUs of the
computer object in AD (remember: you can have nested OUs).

--
S


nki00

unread,
Feb 5, 2012, 5:39:29 PM2/5/12
to
Thanks, I'll need to try.


0 new messages