我工作的最后一个地方是在AD用户和计算机控制台中的每个计算机帐户的说明字段中的AD设置方式,它将说明谁最后login和何时login。 你如何设置它?
很可能,编辑该字段的权限被委派给用户,并且将通过GPO部署将写入该属性的login脚本。 没有内置的function来实现这一点。
这里有一个很早以前放在一起的用户login脚本,它将用户的login名,时间戳和IP地址添加到AD中计算机对象的描述中。 您可以按原样使用,或更改以适合您。 脚本执行后的说明…
On Error Resume Next Set objSysInfo = CreateObject("ADSystemInfo") 'Bind to AD Set objNet = CreateObject("WScript.Network") strCompDN = objSysInfo.ComputerName 'DN for computer, eg "CN=VISTAWORKSTATION,OU=Child OU Name,OU=Parent OU Name,DC=domain,DC=com" Set objComp = GetObject("LDAP://" & strCompDN) 'IADsComputer object strUserDN = objSysInfo.UserName 'DN for user, eg "CN=John Smith,OU=Child OU Name,OU=Parent OU Name,DC=domain,DC=com" Set objUser = GetObject("LDAP://" & strUserDN) 'IADsUser object strUsrLogin = LCase(objNet.UserName) strNow = Now strDateStamp = DatePart("yyyy",strNow) & _ Right("0" & DatePart("m",strNow), 2) & _ Right("0" & DatePart("d",strNow), 2) & _ "@" & _ Right("0" & DatePart("h",strNow), 2) & _ Right("0" & DatePart("n",strNow), 2) 'RegExp object used to perform a simple match on IP address Set objRE = New RegExp objRE.IgnoreCase = True 'Note this regexp pattern isn't "correct" for matching an IPv4 address properly, but since WMI will return an 'array of IP addresses, this is sufficient to distinguish IPv4 vs IPv6 objRE.Pattern = "^\d+\.\d+\.\d+\.\d+$" strIP = "" 'Connect to WMI and retreive all network adapters Set objWMI = GetObject("winmgmts:") Set colNICs = objWMI.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration") 'Get the IP(s) assigned to whichever network adapter has our default gateway If colNICs.Count > 0 Then For Each objNIC in colNICs If IsArray(objNIC.DefaultIPGateway) Then arrIP = objNIC.IPAddress For i = 0 To UBound(arrip) If objRE.Test(arrIP(i)) Then strIP = strIP & " " & arrIP(i) Next strMAC = objNIC.MACAddress End If Next End If strIP = Trim(strIP) objComp.Description = strDateStamp & " " & strUsrLogin & " " & strIP objComp.Put "extensionAttribute1", strUsrLogin objComp.Put "extensionAttribute2", strIP objComp.Put "extensionAttribute3", strMAC objComp.SetInfo
将脚本保存在您的数据中心的SYSVOL共享位置。 然后使用组策略将其分配为用户login脚本。
最后,因为普通用户通常不能改变计算机对象的描述,所以你需要给他们许可,像这样:
添加到MarkM的答案 ,代表完成后,这样的VBScript将做你想要的:
Set objADSystemInfo = CreateObject("ADSystemInfo") Set objLDAPComp = GetObject("LDAP://" & objADSystemInfo.ComputerName) objLDAPComp.Description = objADSystemInfo.UserName & " " & Now() objLDAPComp.SetInfo
这将导致计算机的描述字段被设置为沿着
CN=Joe Blow,OU=The Users,DC=example,DC=com 6/2/2011 10:55:00 AM