hazed Posted June 6, 2008 Posted June 6, 2008 I am trying to add a description after I add a Computer to Active Directory. I used the following code to query the Descriptions, but Now I need to Update them. I tried adding $objectList.Update but that didn't work. $computerName = "DP2CCB1" $filterStr = "(&(objectclass=computer))" $ado = ObjCreate("ADODB.Connection") $ado.Provider = "ADSDSOObject" $ado.Properties("User ID") = "xxxx" $ado.Properties("Password") = "yyyyy" $ado.Properties("Encrypt Password") = 1 $ado.Open ("ADS-Search" ) $adoCmd = ObjCreate("ADODB.Command") $adoCmd.ActiveConnection = $ado ;$adoCmd.Properties("Page Size") = 99 ;$adoCmd.Properties("Cache Results") = 1 ;$adoCmd.CommandText = "<LDAP://" & $serverName & "/" & $baseStr & ">;" & $filterStr & ";ADsPath;subtree" $adoCmd.CommandText = "<LDAP://Cn="&$computername&", OU=Laptops,DC=xxxx,DC=Com>;" & $filterStr & ";ADsPath;subtree" $objectList = $adoCmd.Execute While Not $objectList.EOF() $user = ObjGet($objectList.Fields("ADsPath").value) ConsoleWrite ($user.Name &" "&$user.description& @CRLF) $objectList.MoveNext Wend
Airwolf Posted June 6, 2008 Posted June 6, 2008 I am trying to add a description after I add a Computer to Active Directory. I used the following code to query the Descriptions, but Now I need to Update them. I tried adding $objectList.Update but that didn't work. $computerName = "DP2CCB1" $filterStr = "(&(objectclass=computer))" $ado = ObjCreate("ADODB.Connection") $ado.Provider = "ADSDSOObject" $ado.Properties("User ID") = "xxxx" $ado.Properties("Password") = "yyyyy" $ado.Properties("Encrypt Password") = 1 $ado.Open ("ADS-Search" ) $adoCmd = ObjCreate("ADODB.Command") $adoCmd.ActiveConnection = $ado ;$adoCmd.Properties("Page Size") = 99 ;$adoCmd.Properties("Cache Results") = 1 ;$adoCmd.CommandText = "<LDAP://" & $serverName & "/" & $baseStr & ">;" & $filterStr & ";ADsPath;subtree" $adoCmd.CommandText = "<LDAP://Cn="&$computername&", OU=Laptops,DC=xxxx,DC=Com>;" & $filterStr & ";ADsPath;subtree" $objectList = $adoCmd.Execute While Not $objectList.EOF() $user = ObjGet($objectList.Fields("ADsPath").value) ConsoleWrite ($user.Name &" "&$user.description& @CRLF) $objectList.MoveNext Wend $user.Description = "new description" $user.SetInfo Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt
hazed Posted June 9, 2008 Author Posted June 9, 2008 $user.Description = "new description" $user.SetInfo This failed, I thought I did this earlier, but I tried again C:\Documents and Settings\hazed\Desktop\machine descriptions.au3 (26) : ==> The requested action with this object has failed.: $user.SetInfo $user.SetInfo^ ERROR
Airwolf Posted June 9, 2008 Posted June 9, 2008 This failed, I thought I did this earlier, but I tried againC:\Documents and Settings\hazed\Desktop\machine descriptions.au3 (26) : ==> The requested action with this object has failed.:$user.SetInfo$user.SetInfo^ ERRORDoes the account you are running the program under have appropriate rights to modify the account description you are testing with? Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt
Developers Jos Posted June 9, 2008 Developers Posted June 9, 2008 try: $User.Put ("Description", "Test User description") $User.SetInfo SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
hazed Posted June 10, 2008 Author Posted June 10, 2008 try: $User.Put ("Description", "Test User description") $User.SetInfo This didn't work either, and I do have access. I am wondering if ADO can modify Active Directory. One website I found, mentioned something to that effect. Which makes sense to me.
Jackized Posted February 15, 2012 Posted February 15, 2012 #include <AD.au3> _AD_Open() _AD_ModifyAttribute("John Doe", "Description", "Lost in time") _AD_Close()
water Posted February 16, 2012 Posted February 16, 2012 A bit late - the thread is 3 1/2 years old - but glad you use my UDF 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now