Ivo Posted January 18, 2011 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
sleepydvdr Posted January 18, 2011 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>
water Posted January 18, 2011 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 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
Ivo Posted January 19, 2011 Author 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
Ivo Posted January 19, 2011 Author 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
water Posted January 19, 2011 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 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
Ivo Posted January 21, 2011 Author 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
water Posted January 21, 2011 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 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