stoffmann Posted December 7, 2010 Share Posted December 7, 2010 Hello,i have a vbscript that does what i need. I looks like this.Dim DomainName Dim UserAccount Set net = WScript.CreateObject("WScript.Network") local = net.ComputerName UserAccount = "ww900/Teamgroup" set group = GetObject("WinNT://"& local &"/Administrators") on error resume next group.Add "WinNT://"& UserAccount &"" CheckError sub CheckError if not err.number=0 then set ole = CreateObject("ole.err") WScript.echo ole.oleError(err.Number), vbCritical err.clear else WScript.echo "Done." end if end subI've tried to translate this to AutoIt and ended up with this (found in the forum)Dim $UserGroup, $UserName $UserGroup = "administrators" $UserName = "ww900/Teamgroup" ;Add User to group $objGroup = ObjGet("WinNT://" & @ComputerName & "/" & $UserGroup & ",group") $objUser = ObjGet("WinNT://" & $UserName & ",user") If Not $objGroup.IsMember($objUser.AdsPath) Then $objGroup.Add ($objUser.AdsPath) ConsoleWrite("User added") Else ConsoleWrite("Failed to add user") EndIfThe AutoIt code works if i the user is in the same domain as the computer, but not if the user is from an other domain.What am i doing wrong?I found this but i have no ideaon how to use this script works. Thank's in advanceStefan Link to comment Share on other sites More sharing options...
water Posted December 7, 2010 Share Posted December 7, 2010 Just a shot in the dark but I think you'll have to add the domain where you want to search for the user. Something like:$objUser = ObjGet("WinNT://" & $Domain "\" & $UserName & ",user") My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
stoffmann Posted December 7, 2010 Author Share Posted December 7, 2010 Just a shot in the dark but I think you'll have to add the domain where you want to search for the user. Something like:$objUser = ObjGet("WinNT://" & $Domain "\" & $UserName & ",user") Thank's for the hint, but i allready have the domain in the variable $UserName = "ww900/Teamgroup". Link to comment Share on other sites More sharing options...
water Posted December 7, 2010 Share Posted December 7, 2010 Ahhh, I see. I don't know if that makes a difference but usually I use a backslash between domain and username e.g. $UserName = "ww900\Teamgroup". My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
spudw2k Posted December 7, 2010 Share Posted December 7, 2010 Are you aware of there being domain trusts in place? Can you currently perform cross domain authentication? Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
stoffmann Posted December 8, 2010 Author Share Posted December 8, 2010 Ahhh, I see. I don't know if that makes a difference but usually I use a backslash between domain and username e.g. $UserName = "ww900\Teamgroup".You're right, backslash is the normal syntax.I tried both variants in the AutoIt script. The VBScript works with the slash.Thanks Link to comment Share on other sites More sharing options...
stoffmann Posted December 8, 2010 Author Share Posted December 8, 2010 Are you aware of there being domain trusts in place? Can you currently perform cross domain authentication?The domains are trusted. As i said, the vbscript doing the same (as far es i can see) works.Thank You Link to comment Share on other sites More sharing options...
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