Jump to content

How can I change AD user last name with water UDF ? [Solved]


Nas
 Share

Recommended Posts

I was stuck on changing some areas on my username for some reason please check the script below :

#include <AD.au3>
#RequireAdmin

_AD_Open()

; this portion works just fine
_AD_ModifyAttribute("User.a", "GivenName", "John")
_AD_ModifyAttribute("User.a", "displayName", "John, Smith") 

; this portion I can't get it to work
_AD_ModifyAttribute("User.a", "Surname", "Smith")           
_AD_ModifyAttribute("User.a", "City", "Orlando")
_AD_ModifyAttribute("User.a", "State", "FL")
_AD_ModifyAttribute("User.a", "country", "US")

_AD_Close()

Basically the top portion for the Givenname and display name works perfectly but the other portion I am unable to get it to work.

Edited by Nas
Link to comment
Share on other sites

Try the following modification to get better error information:

Quote
#include <AD.au3>
#RequireAdmin

_AD_Open()

_AD_ErrorNotify(2)
; this portion works just fine
_AD_ModifyAttribute("User.a", "GivenName", "John")
_AD_ModifyAttribute("User.a", "displayName", "John, Smith") 

; this portion I can't get it to work
_AD_ModifyAttribute("User.a", "Surname", "Smith")           
_AD_ModifyAttribute("User.a", "City", "Orlando")
_AD_ModifyAttribute("User.a", "State", "FL")
_AD_ModifyAttribute("User.a", "country", "US")

_AD_Close()

 

 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

This simply means that the corresponding property has not been set before.

What is the value of @error and @extended after calling _AD_ModifyAttribute?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Or run the example script for _AD_GetObjectProperties. Example 1 will list all properties of the current user.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Awesome, Thank you @AdamUL thanks @water you're the best.

here is how my script looks like now, wanted to share, maybe someone will need this in the future :

#include <AD.au3>

_AD_Open()

_AD_ModifyAttribute("User.a", "GivenName", "John")
_AD_ModifyAttribute("User.a", "displayName", "John, Smith")
_AD_ModifyAttribute("User.a", "Description", "Owner")
_AD_ModifyAttribute("User.a", "physicalDeliveryOfficeName", "Downtown")
_AD_ModifyAttribute("User.a", "Title", "Admin")
_AD_ModifyAttribute("User.a", "Department", "IT")
_AD_ModifyAttribute("User.a", "proxyAddresses", "SMTP:John.Smith@server.com")
_AD_AddEmailAddress("User.a", "John.Smith@server.local")
_AD_ModifyAttribute("User.a", "mail", "John.Smith@server.com")
_AD_ModifyAttribute("User.a", "StreetAddress", "100 N Highway")
_AD_ModifyAttribute("User.a", "Title", "SysAdmin")
_AD_ModifyAttribute("User.a", "Company", "Facebook")
_AD_ModifyAttribute("User.a", "PostalCode", "60000")
_AD_ModifyAttribute("User.a", "Manager", _AD_GetObjectAttribute("John.Smith", "distinguishedName")) ; here will assign john smith as manager for user.a
_AD_ModifyAttribute("User.a", "sn", "Smith")
_AD_ModifyAttribute("User.a", "l", "Orlando")
_AD_ModifyAttribute("User.a", "st", "FL")
_AD_ModifyAttribute("User.a", "c", "US")

_AD_Close()

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...