Help with VB Script - Get the Managers sAmAccountName?

Anything VBScript-related, including Windows Script Host, WMI, ADSI, and more.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 9 years and 1 month old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Help with VB Script - Get the Managers sAmAccountName?

Post by jvierra »

maries wrote:This is definitely a much bigger task than I expected. I've found other posts and it appears you can't pull the info I want like this.
You absolutely can and we do it all of the time. I just showed you how to do it. If you can get someone at you work to help you understand how this works I think you will see what I mean.
User avatar
Maries
Posts: 17
Last visit: Mon Feb 09, 2015 12:00 pm

Re: Help with VB Script - Get the Managers sAmAccountName?

Post by Maries »

Hello,

Thank you for the continued help. I spent about 3 hours on this today with a consultant that works for MS implementing SharePoint, among other things.

We looked over the entire script and sql job. Then viewed the database tables. In the database now the managers dn is populating.

When we tried using the updated command you provided we got an error back and it was "ActiveX scripting error", then in the log was a reference to the line we put this command on.

We then tried to put the Get portion of the command under the "AddNew" section of the script you will see in the file I uploaded. Then we set the sqlrecordset as you had provided in this latest update, but then it failed again with errors related to both lines.

Next we went back and tried to use the original command you provided and he tried a couple different versions of that, and then also specifying the sql record set and ado field, but we hit the same error.

We searched quite a bit online and he sent a message to a couple of his colleagues, and he's waiting to hear back. What we found online were only posts where people did this using VB, but they all seemed to do the same thing. They had to pull the managers and create a "dictionary" that was stored as a variable in the script, then read later on in the script when the attribute was pulled. Does that make sense? I can post the links to the forums we found this on. This engineer stated the same as you did and what I thought, it would be easier in powershell, but we can't switch it. They also stated that the syntax looked off in regards to the ".value). Samaccountname, is it possible that there's supposed to be something else there? He wasn't positive but was going to try to mess with it more tonight. He's done a fair amount of VB, but stated he wasn't an expert as he focuses on C# and Posh.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Help with VB Script - Get the Managers sAmAccountName?

Post by jvierra »

I am sorry but the code I posted woorks with no issue. If you have a consultant tht has gotten you working then good luck.
User avatar
Maries
Posts: 17
Last visit: Mon Feb 09, 2015 12:00 pm

Re: Help with VB Script - Get the Managers sAmAccountName?

Post by Maries »

Thanks again. I got a reply back from MS and they stated that the code provided wouldn't work in this example.

They plan to get the manager first and then write another piece that reads rhe list if managers.

I tried for 3 hours more tonight and nothing works.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Help with VB Script - Get the Managers sAmAccountName?

Post by jvierra »

Maries wrote:Thanks again. I got a reply back from MS and they stated that the code provided wouldn't work in this example.

They plan to get the manager first and then write another piece that reads rhe list if managers.

I tried for 3 hours more tonight and nothing works.
The code works absolutely fine. I have staged it a and it has no issues. Getting a manager like that is exactly how Microsoft documents it.

I have been doing this for many years. I havebeen using that code for many years. I haveno idea what you showed the MS person. Since youdo not understand programming it is possible and likely that you gave them the wrong information.

I have fixed your originalcode and have it working smoothly. I did it just so I could findout what your issues were. My instructions were correct. I don't see how I cando any more. If you stil need help I recommend contacting a consultant to help you sort through this.

I think we can just agree that I failed to communicate andleave it at that.
User avatar
Maries
Posts: 17
Last visit: Mon Feb 09, 2015 12:00 pm

Re: Help with VB Script - Get the Managers sAmAccountName?

Post by Maries »

I appreciate the help, you are correct that I don't know how to write the code. However I do understand what is being done in most of the script. I would not waste your time as I appreciate the help. I didn't give them the code, I gave the consultant the link to this thread and they went through the entire script as well as the snippets you provided.

Can you paste a sample of the script you have that works so I can see exactly what you added and where? If you can tell me what line it should be on and following what portion of the existing script that might help.

The error is very clear, I can provide it entirely as we disabled the continue on error statements, they are commented out. Everything that we have found states the managers dn has to be pulled first and stored in an object and then queried later in the script. Is that correct?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Help with VB Script - Get the Managers sAmAccountName?

Post by jvierra »

You waited until I closed it out of the queue so now I have to go find it.
Attachments
AdToSQLServer.vbs
(8.54 KiB) Downloaded 429 times
User avatar
Maries
Posts: 17
Last visit: Mon Feb 09, 2015 12:00 pm

Re: Help with VB Script - Get the Managers sAmAccountName?

Post by Maries »

I apologize for the issues with asking this question. Thanks for the help and it might be frustrating to help new people learn this, but at least being less insulting might make people more comfortable posting to forums like this and this is why I never do. It's my 1st and last post.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Help with VB Script - Get the Managers sAmAccountName?

Post by jvierra »

Maries wrote:I apologize for the issues with asking this question. Thanks for the help and it might be frustrating to help new people learn this, but at least being less insulting might make people more comfortable posting to forums like this and this is why I never do. It's my 1st and last post.
I don't believe I am not being insulting. This is not really a forum for free consulting. I answered you question days ago. You agreed that the example returned what you needed.

I have tried to be patient but you seem to have no understanding of scripting or debugging techniques. It is beyond the scope of most technical forums to give individual training to users.

There are numerous books available to help you learn how to script and to help learn how to use AD and SQLServer. You might want to start with those and do the examples until you understand the material. You can then post specific questions and move forwards more easily.

Again, please understand that the scope of forums is limited and usually allows a single question or issue. Your script is a problem due to the fact the error management is turned off and that you are trying to batch when you may have nulls that need to be handled or you may have values of the wrong type. This will cause you batch to have hidden errors.

I noted all of this in the beginning. I have scripted Ad and SQLServer for many years. Please try to understand that these things are not trivial. If you search for VBScript error management you will find many articles on this topic. Without proper error management it is very hard to understand how to assist you without redesigning your script and without knowing what the DB schema looks like.

If this is important I recommend hiring a trained consultant. You should seek a consultant that is Microsoft certified in AD and SQLServer as well experienced in scripting.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Help with VB Script - Get the Managers sAmAccountName?

Post by jvierra »

Maries wrote:I apologize for the issues with asking this question. Thanks for the help and it might be frustrating to help new people learn this, but at least being less insulting might make people more comfortable posting to forums like this and this is why I never do. It's my 1st and last post.
I am still trying to see what you think was insulting. I would appreciate it if you could show me what wording appeared t obe that way\.

Thank you.
This topic is 9 years and 1 month old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked