Hi,

Can anyone, please, help me with some code. I'm looking for a VB script to
resolve the OU of the current user. This way I want to create the LDAP path
of the current logged in user automatically. Anyone some ideas?

Best regards,

Jerry

Re: resolve OU current user by Richard

Richard
Tue Mar 14 15:01:01 CST 2006

Jerry wrote:

> Can anyone, please, help me with some code. I'm looking for a VB script to
> resolve the OU of the current user. This way I want to create the LDAP
> path
> of the current logged in user automatically. Anyone some ideas?

Hi,

If the client is Windows 2000 or above, use the ADSystemInfo object to
retrieve Distinguished Name (DN) of user. For example:

Set objSysInfo = CreateObject("ADSystemInfo")
strUserDN = objSysInfo.UserName

Set objUser = GetObject("LDAP://" & strUserDN)

The OU of the user is seldom needed, but if necessary, you can either parse
the DN of the user, or get the DN of the OU from the Parent property method
of the user object.

strOU_DN = objUser.Parent

--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net



Re: resolve OU current user by otto

otto
Tue Mar 14 15:58:29 CST 2006


> Hi,
>
> If the client is Windows 2000 or above, use the ADSystemInfo object to
> retrieve Distinguished Name (DN) of user. For example:
>
> Set objSysInfo = CreateObject("ADSystemInfo")
> strUserDN = objSysInfo.UserName
>
> Set objUser = GetObject("LDAP://" & strUserDN)
>
> The OU of the user is seldom needed, but if necessary, you can either parse
> the DN of the user, or get the DN of the OU from the Parent property method
> of the user object.
>
> strOU_DN = objUser.Parent
>
> --
> Richard
> Microsoft MVP Scripting and ADSI
> Hilltop Lab - http://www.rlmueller.net
>

Thx Richard,

I will try this out. In this case I need the OU because we have different
branch offices. Every office has is own OU and the "Power" user has to be
able to list all the users in his OU. And isn't allowed to get the users of
an other OU. The users are not technicians, so the list should be showed
without input from the user. To keep things dynamic (and cause I'm lazy:) I
donâ??t want to manually put in all possible LDAP paths.

Grtz,

Jerry