|
mrmovie (TechnicalUser) |
26 Feb 03 5:42 |
below gets it from exchange, we dont populate ad with the upto date information.
ad query would be
'######## strUser = InputBox("Enter your name")
Set user = GetObject("WinNT://domfsc01/" & strUser & ",user")
msgbox user.Profile
'#####
but i am not sure what the property for the mail address is
'#######
Set WshShell = WScript.CreateObject("WScript.Shell") Set WshNetwork = WScript.CreateObject("WScript.Network") Set oCommand = CreateObject("ADODB.Command") Set oConnection = CreateObject("ADODB.Connection") oConnection.Provider = "ADsDSOObject" oConnection.Open = "Active Directory Provider" oCommand.ActiveConnection = oConnection oCommand.Properties("Page Size") = 100 oCommand.Properties("Timeout") = 30 oCommand.Properties("Searchscope") = 2 oCommand.Properties("Cache Results") = False
Set oRS = oConnection.Execute("SELECT mail,uid,sn,givenName FROM 'LDAP://abg0970e.abg.fsc.net' WHERE uid='" & WshNetwork.Username & "'")
'While Not oRS.EOF If oRS.RecordCount = 1 Then For i = 0 To oRS.Fields.Count - 1 If IsArray(oRS.Fields(i).value) Then aArray = oRS.Fields(i).Value If oRS.Fields(i).Name = "sn" Then strSN = aArray(0) ElseIf oRS.Fields(i).Name = "givenName" Then strGN = aArray(0) End If 'msgbox oRS.Fields(i).Name & ": " & aArray(0) WshShell.RegWrite "HKCU\Software\WASP\NetWorker Laptop_6.2_EN\" & oRS.Fields(i).Name, aArray(0) Else If oRS.Fields(i).Name = "sn" Then strSN = oRS.Fields(i) ElseIf oRS.Fields(i).Name = "givenName" Then strGN = oRS.Fields(i) End If
'msgbox oRS.Fields(i).Name & ": " & oRS.Fields(i) WshShell.RegWrite "HKCU\Software\WASP\NetWorker Laptop_6.2_EN\" & oRS.Fields(i).Name, oRS.Fields(i).Value End If Next 'oRS.MoveNext WshShell.RegWrite "HKCU\Software\WASP\NetWorker Laptop_6.2_EN\commonNameNational", strGN & " " & strSN Else WshShell.RegWrite "HKCU\Software\WASP\NetWorker Laptop_6.2_EN\sn", strUserName WshShell.RegWrite "HKCU\Software\WASP\NetWorker Laptop_6.2_EN\mail", strUserName & "@fujitsu-siemens.com" WshShell.RegWrite "HKCU\Software\WASP\NetWorker Laptop_6.2_EN\commonNameNational", strUserName
End If 'Wend Set oRS = Nothing Set oConnection = Nothing Set oCommand = Nothing Set WshNetwork = Nothing Set WshShell = Nothing |
|