Here it is...

Option Explicit
Dim oUser
Dim usercontainer
Dim rootDN
Dim WshNetwork
Dim conn

On Error Resume Next

rootDN="DOMAIN NAME"

'=== Get a reference to the WScript.Network object so we can
'    get the computer name we are logged into. 
Set WshNetwork = CreateObject("WScript.Network")
'=== Establish connection to our Active Directory
Set Conn = CreateObject("ADODB.Connection")
conn.Provider = "ADSDSOObject"
conn.Open "ADs Provider"


Dim RS
Dim query
Dim dn
Dim lastLogon

query = "<LDAP://" & rootDN & ">;(&(ObjectClass=User)" & _
        "(sAMAccountName=" & WshNetwork.UserName & "));" & _
        "distinguishedName,samAccountName,wwwHomePage,url;subtree"
Set RS = conn.Execute(cstr(query))

IF RS.EOF Then
    WScript.Echo "Please call the help desk"
    Wscript.Quit 1
End If

dn = RS("distinguishedName")
Set oUser = GetObject("LDAP://" & dn)


lastLogon = RS("wwwHomePage")
IF Not(IsNull(lastLogon)) Then
        oUser.Put "url",lastLogon
End If
oUser.Put "wwwHomePage",WshNetwork.ComputerName
oUser.SetInfo

Mike



Mike O'Sullivan
IT Expert
College of Veterinary Medicine
352.392.4700x4343
>>> [EMAIL PROTECTED] 12/03/05 1:23 PM >>>
Hi Mike

Interested in your method as well, appreciate if you have something on this
:) 



Thank you and have a splendid day!

Kind Regards,

Freddy Hartono
Group Support Engineer
InternationalSOS Pte Ltd
mail: [EMAIL PROTECTED]
phone: (+65) 6330-9785

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Mike O'Sullivan
Sent: Friday, December 02, 2005 9:22 PM
To: [EMAIL PROTECTED]; ActiveDir@mail.activedir.org
Subject: Re: [ActiveDir] Getting computer name from a username

Since we dont use the webpage in the user account properties, we have a
startup script that puts the username into the webpage properties.  Wherever
the user has logged in from, it will enter the computer name in the webpage
box.  It changes with each login.  Let me know if you/anyone else is
interested





Mike O'Sullivan
IT Expert
College of Veterinary Medicine
352.392.4700x4343

>>> [EMAIL PROTECTED] 12/1/2005 4:49:39 AM >>>
Hi,

Is there a way you can tell which computer a user has logged onto just from
his username?



--
Shane De Jager
Technical Developer

INTERGAGE
High-performance, updateable Web sites

Switchboard   +44 (0)845 456 1022
==
www.intergage.co.uk
[EMAIL PROTECTED] 

Are you aware of our referral scheme? Learn how you could profit personally
from passing us leads.

Click here to pass a referral: www.intergage.co.uk/referrals 
List info   : http://www.activedir.org/List.aspx 
List FAQ    : http://www.activedir.org/ListFAQ.aspx 
List archive: http://www.mail-archive.com/activedir%40mail.activedir.org/

List info   : http://www.activedir.org/List.aspx
List FAQ    : http://www.activedir.org/ListFAQ.aspx
List archive: http://www.mail-archive.com/activedir%40mail.activedir.org/
List info   : http://www.activedir.org/List.aspx
List FAQ    : http://www.activedir.org/ListFAQ.aspx
List archive: http://www.mail-archive.com/activedir%40mail.activedir.org/

List info   : http://www.activedir.org/List.aspx
List FAQ    : http://www.activedir.org/ListFAQ.aspx
List archive: http://www.mail-archive.com/activedir%40mail.activedir.org/

Reply via email to