Notification

Icon
Error

Updating Active Directory User fields

Posted: Thursday, January 7, 2021 5:49:03 PM(UTC)
Nuno

Nuno

Member Original PosterPosts: 1
0
Like
Hi, is it possible to create a custom action to update Active Directory User's field (like Mobile phone, IP Phone, Office, etc.) through Lansweeper?
Don
#1Don Member Posts: 33  
posted: 11/2/2021 8:21:46 PM(UTC)
Yes, we use this user action to modify user phone in AD:

{actionpath}modUser_PhExt.vbs "{username}"




And here is the content of "modUser_PhExt.vbs" script:


Code:


Option Explicit
Dim strUser, rootDSE, adoConnection, ldapStr, adoRecord, objUser, strExt, objExt, strMsg, choice

' Change the attribute in the 4 numbered locations and save as new VBS.

struser = WScript.Arguments(0)

Set rootDSE = GetObject("LDAP://RootDSE")
Set adoConnection = CreateObject("ADODB.Connection")
adoConnection.Provider = "ADSDSOObject"
adoConnection.Open "ADs Provider"

ldapStr = "<LDAP://" & rootDSE.Get("defaultNamingContext") & ">;(&(objectCategory=Person)(objectClass=User)(samAccountName=" & strUser & "));adspath;subtree"

Set adoRecord = adoConnection.Execute(ldapStr)
Set objUser = GetObject (adoRecord.Fields(0).Value)

' 1

strMsg = "The current extension is: " & objUser.telephoneNumber & VbCrLf & VbCrLf & _
    "Do you want to change this user's extension in AD?"

choice = MsgBox(strMsg,4,"Change Extension?")

If choice = 6 Then

' 2

strExt = Inputbox("Enter Extension:","Enter Extension",objUser.telephoneNumber)

If Not adoRecord.EOF Then
    On Error Resume Next

' 3
        objUser.Put "telephoneNumber", "" & strExt
        objUser.SetInfo
    On Error GoTo 0
End If

End If

'Set objExt = GetObject("LDAP://" & objUser.distinguishedName)

' 4

MsgBox "Extension: " & objUser.telephoneNumber,0,"User's Extension"

Active Discussions

Lansweeper Lansweeper Dark Theme
by  mrobbins   Go to last post Go to first unread
Last post: Yesterday at 5:38:01 PM(UTC)
Lansweeper Detect Docking Stations
by  GlenH  
Go to last post Go to first unread
Last post: Yesterday at 3:52:13 PM(UTC)
Lansweeper Exclude non-windows assets from scanning by assetname
by  rapheren   Go to last post Go to first unread
Last post: Yesterday at 1:18:12 PM(UTC)
Lansweeper HTTPS Certifikate untrusted
by  pskup  
Go to last post Go to first unread
Last post: Yesterday at 9:20:07 AM(UTC)
Lansweeper Migrate to new host but without SQL
by  pskup   Go to last post Go to first unread
Last post: Yesterday at 9:03:14 AM(UTC)
Lansweeper Object reference error after updating to 10.2.0.0
by  Erik.T  
Go to last post Go to first unread
Last post: Yesterday at 8:10:25 AM(UTC)
Lansweeper Custom reporting - Asset Groups and AD Description
by  rbshawn   Go to last post Go to first unread
Last post: 6/29/2022 10:54:10 PM(UTC)
Lansweeper A FIX for an odd Scan Error WMI/DCOM from scanning server
by  danielm  
Go to last post Go to first unread
Last post: 6/29/2022 10:14:44 PM(UTC)