Ivo 0 Posted January 18, 2011 Hi all I am using the _AD_AddUserToGroup from ad.au3 to add users to an AD Group. It work fine as long as I dont have users with an / in the FQDN. If there is a "/" in the FQDN I got the error number -2147352567 from @error #include <AD.au3> _AD_Open() ;This doesn't work _AD_AddUserToGroup("CN=SG-ALL-Employees,OU=Security Groups,OU=GROUPS,DC=OFFICE,DC=ORG","CN=Jan Jansen (ATF/G),OU=NL,OU=Users,DC=OFFICE,DC=org") ;This works fine _AD_AddUserToGroup("CN=SG-ALL-Employees,OU=Security Groups,OU=GROUPS,DC=OFFICE,DC=ORG","CN=Klaas Vaak (BDF-R),OU=NL,OU=Users,DC=OFFICE,DC=org") _AD_Close() Any ideas? Thanks in advance Ivo Ivo Share this post Link to post Share on other sites
sleepydvdr 8 Posted January 18, 2011 I cannot test this, so I don't know if it will work. It's worth a try. $forwardslash = chr (47) _AD_AddUserToGroup("CN=SG-ALL-Employees,OU=Security Groups,OU=GROUPS,DC=OFFICE,DC=ORG","CN=Jan Jansen (ATF" & $forwardslash & "G),OU=NL,OU=Users,DC=OFFICE,DC=org") #include <ByteMe.au3> Share this post Link to post Share on other sites
water 2,425 Posted January 18, 2011 (edited) You have to escape the slash. Use "\/" instead of "/". Or use the internal function _AD_FixSpecialChars. $sResult = _AD_FixSpecialChars($sString, <0 = escape, 1 = unescape>, "<list of characters to escaep/unescape>") Edited January 19, 2011 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2021-04-14 - Version 1.5.3.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (NEW 2021-04-13 - Version 1.6.4.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (NEW 2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - WikiTask Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - WikiTutorials:ADO - Wiki, WebDriver - Wiki Share this post Link to post Share on other sites
Ivo 0 Posted January 19, 2011 I tried this but it didn't work. I cannot test this, so I don't know if it will work. It's worth a try. $forwardslash = chr (47) _AD_AddUserToGroup("CN=SG-ALL-Employees,OU=Security Groups,OU=GROUPS,DC=OFFICE,DC=ORG","CN=Jan Jansen (ATF" & $forwardslash & "G),OU=NL,OU=Users,DC=OFFICE,DC=org") Ivo Share this post Link to post Share on other sites
Ivo 0 Posted January 19, 2011 (edited) You have to escape the slash. Use "\/" instead of "/". Or use the internal function _AD_FixSpecialChars. $sResult = _AD_FixSpecialChars($sString, <0 = escape, 1 = unescape>, "<list of characters to escaep/unescape>") _AD_AddUserToGroup("CN=SG-ALL-Employees,OU=Security Groups,OU=GROUPS,DC=OFFICE,DC=ORG","CN=Jan Jansen (ATF\/G),OU=NL,OU=Users,DC=OFFICE,DC=org") or $sResult = _AD_FixSpecialChars("CN=Jan Jansen (ATF/G),OU=NL,OU=Users,DC=OFFICE,DC=org") _AD_AddUserToGroup("CN=SG-ALL-Employees,OU=Security Groups,OU=GROUPS,DC=OFFICE,DC=ORG",$sResult) Doesn't work. It says that the user doesn't exis in the AD. But it has something to do with the _AD_FixSpecialChars Func. I got it to work with the following lines: $SamID = _AD_FQDNToSamAccountName("CN=Jan Jansen (ATF/G),OU=NL,OU=Users,DC=OFFICE,DC=org") _AD_AddUserToGroup("CN=SG-ALL-Employees,OU=Security Groups,OU=GROUPS,DC=OFFICE,DC=ORG",$SamID) and those lines use the _AD_FixSpecialChars Function internally. Thanks for you help. Edited March 20, 2011 by Jos Ivo Share this post Link to post Share on other sites
water 2,425 Posted January 19, 2011 I see. The problem was with the call to _AD_FixSpecialChars and using default parameters.$sResult = _AD_FixSpecialChars("CN=Jan Jansen (ATF/G),OU=NL,OU=Users,DC=OFFICE,DC=org")gets a result of CN=Jan Jansen (ATF\/G)\,OU=NL\,OU=Users\,DC=OFFICE\,DC=orgwhich is incorrect because the commas are escaped as well.The line$sResult = _AD_FixSpecialChars("CN=Jan Jansen (ATF/G),OU=NL,OU=Users,DC=OFFICE,DC=org", 0, "/")returns the correct result ofCN=Jan Jansen (ATF\/G),OU=NL,OU=Users,DC=OFFICE,DC=orgDo you think I should change _AD_FixSpecialChars into a "normal" function and insert extended documentation and examples? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2021-04-14 - Version 1.5.3.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (NEW 2021-04-13 - Version 1.6.4.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (NEW 2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - WikiTask Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - WikiTutorials:ADO - Wiki, WebDriver - Wiki Share this post Link to post Share on other sites
Ivo 0 Posted January 21, 2011 The function has helped me so I think it is a good idea to add it to the "normal" functions. My script is ready now and implemented in our organisation. Thanks again. Ivo Share this post Link to post Share on other sites
water 2,425 Posted January 21, 2011 Thanks for your reply. Will be a part of the next version. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2021-04-14 - Version 1.5.3.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (NEW 2021-04-13 - Version 1.6.4.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (NEW 2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - WikiTask Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - WikiTutorials:ADO - Wiki, WebDriver - Wiki Share this post Link to post Share on other sites