Re: Script by Slim
Slim
Sat Apr 15 09:58:37 CDT 2006
"Anderson" <Anderson@discussions.microsoft.com> wrote in message
news:E2199528-296A-4B8C-B934-1BB50FEB3134@microsoft.com...
> Hi Slim,
>
> I tryied to run your script but it gives me back an error:
> line 4: dim oUser:set oUser = GetObject("LDAP://"& getUserDN( dUser) )
> Error: unknown type "getUserDN(dUser))"
>
did you change this line to fit your domain?
SELECT distinguishedName FROM 'LDAP://dc=thatsit,dc=local' WHERE
> Thanks,
> Anderson
>
>
> "Slim" wrote:
>>
>> "Anderson" <Anderson@discussions.microsoft.com> wrote in message
>> news:306F1686-D1C1-43FA-857F-E6FCD49F3527@microsoft.com...
>> > Hi all,
>> >
>> > I am trying to write a script to do as follow: when a user loging in
>> > the
>> > AD
>> > a window will pop-up showing with the message: user name, you belong to
>> > group
>> > name
>> >
>> > If anyone has something like that I appreciate,
>> >
>> > Thanks,
>> > Anderson
>>
>>
>> dim network:Set network = CreateObject("WScript.Network")
>> dim dUser: dUser = network.UserName
>>
>> dim oUser:set oUser = GetObject("LDAP://"& getUserDN( dUser) )
>>
>> For Each grp In oUser.Groups
>> Msgbox grp.Name
>> Next
>>
>>
>>
>> function getUserDN(userName)
>> On Error Resume Next
>> Const ADS_SCOPE_SUBTREE = 10
>> Set objConnection = CreateObject("ADODB.Connection")
>> Set objCommand = CreateObject("ADODB.Command")
>> objConnection.Provider = "ADsDSOObject"
>> objConnection.Open "Active Directory Provider"
>> Set objCommand.ActiveConnection = objConnection
>> objCommand.Properties("Page Size") = 1000
>> objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
>> objCommand.CommandText = _
>> "SELECT distinguishedName FROM 'LDAP://dc=thatsit,dc=local' WHERE
>> objectCategory='user' " & _
>> "AND sAMAccountName='"& userName &"'"
>> Set objRecordSet = objCommand.Execute
>> dim ans
>> objRecordSet.MoveFirst
>> Do Until objRecordSet.EOF
>> ans = objRecordSet.Fields("distinguishedName").Value
>> objRecordSet.MoveNext
>> Loop
>> getUserDN = ans
>> end function
>>
>>
>>
>>