Query an attribute of an OU object that a mailbox user is located in.
greetings,
i have created mailbox billing spreadsheet in form of csv pulls data multiple sources exchange 2007 enviornment (running on windows 2008). have in report need except 1 value (of course). missing value need populate billing code have stored in the "businesscategory" attribute of the ou user object in. i.e. track billing code of users today in ou belong (i know there other ways this, our method today).
i can user's ldap dn get-mailbox in ldap query friendly form. ie: "cn=user\, joe (code),ou=ou3,ou=ou2,ou=ou1,dc=company,dc=com"
i can ou in, it's in the "company.com/ou1/ou2/ou3" format isn't ldap query friendly.
i figured out powershell commands required attribute off of ou format of:
$ou = [adsi]"ldap://ou=ou3,ou=ou2,ou=ou1,dc=company,dc=com"
$ou.get("businesscategory")
i can't quite figure out how ou path of ad user object adsi query.
i thought using , delimeter , splitting dn of user 2 [pieces], objects have \, in cn due fact users stored in ad "lastname, firstname (code)", , other objects resource accounts don't. don't think trying extract ou dn going easy.
i think creating code turn non-ldap friendly ou path ldap friendly ou path potentially painful , there has better way that.
does have suggestions? thought trying userobject.parent("businesscategory") query, syntax eluding me. did try various internet , forum searches before posting, trying seems uncommon.
thanks!
try this:
$dn = "cn=user\, joe (code),ou=ou3,ou=ou2,ou=ou1,dc=company,dc=com" $user = [adsi]"ldap://$dn" $name = ($user.psbase.parent).distinguishedname write-host $name
Windows Server > Windows PowerShell
Comments
Post a Comment