HTA/VBS Noob question

Batch, ASP, JScript, Kixtart, etc.
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.
User avatar
jvierra
Posts: 13502
Joined: Tue May 22, 2007 9:57 am
Contact:

HTA/VBS Noob question

Post by jvierra » Mon Aug 16, 2010 5:45 am

Please post teh exact vbscript you aretrying to run. I need to see it. It is clear that you are no understanding what we need to do.

This script is what you need to edit to put in the sUser name between the quotes. It needs to be an actual CN name of a user. The rest of the script that adds the user to groups is your script and domain. If it is giving an error there you need to fix that too.

Of the LDAP string is incorret then you need to correct that. I cannot know what your domain looks like.

Code: Select all

sUser = "blah, blah"  ' replace balh blah with a user CN.
'ProcessUser sUser
'ProcessUser "" & sUser & ""
Function ProcessUser( strUser, strOU ) 
        
        'Add User to Group
        strUserDN = Replace("LDAP://CN=XXXXX,OU=Standard,OU=Managed Users,DC=MFI,DC=domain,DC=PVT","XXXXX", strUser )
        Set objUser = GetObject(strUserDN)
        Set objGroup = GetObject("LDAP://CN=TSM_BackupUsers,OU=Application Rights, OU=Groups, OU=Managed Users,DC=MFI,DC=domain,DC=PVT")
        objGroup.add objUser.ADsPath
    
        Set oGrp = GetObject("WinNT://./Power Users")
        set oGrp1 = GetObject("WinNT://./Backup Operators")
        Set oUsr = GetObject("WinNT://MFI.domain.pvt/Domain Users")
        oGrp.Add oUsr.ADsPath
        oGrp1.Add oUsr.ADsPath
        
        ProcessUser = true
        
    End Function

When you have edited and tested this post the exact script you have used along with teh exact error message in it's entirety. All words and numbers in the error message. You can just copy it from the console Window to the clipboard and past it into a message.

User avatar
jvierra
Posts: 13502
Joined: Tue May 22, 2007 9:57 am
Contact:

HTA/VBS Noob question

Post by jvierra » Mon Aug 16, 2010 6:27 am

Once again - I want you to do this with vbscript and NOT an HTA. Please use the VBS and give me your script and the exact ewrror message.

User avatar
jvierra
Posts: 13502
Joined: Tue May 22, 2007 9:57 am
Contact:

HTA/VBS Noob question

Post by jvierra » Mon Aug 16, 2010 7:02 am

Would you please use the exact code method I posted for you. I want you to use the function. That is the whole point of this. If you can make the function work you can use it in an HTA. First we make the function work from a vbs file.

Please use the function in the VBS file as I posted it. Use first on ethen the other of the function calls with you user name. Don't forget to fix teh domain name.

Code: Select all

sUser = "Albers, Guy R."  ' replace balh blah with a user CN.
'ProcessUser sUser
'ProcessUser "" & sUser & ""
Function ProcessUser( strUser, strOU ) 
        
        'Add User to Group
        strUserDN = Replace("LDAP://CN=XXXXX,OU=Standard,OU=Managed Users,DC=MFI,DC=domain,DC=PVT","XXXXX", strUser )
        Set objUser = GetObject(strUserDN)
        Set objGroup = GetObject("LDAP://CN=TSM_BackupUsers,OU=Application Rights, OU=Groups, OU=Managed Users,DC=MFI,DC=domain,DC=PVT")
        objGroup.add objUser.ADsPath
    
        Set oGrp = GetObject("WinNT://./Power Users")
        set oGrp1 = GetObject("WinNT://./Backup Operators")
        Set oUsr = GetObject("WinNT://MFI.domain.pvt/Domain Users")
        oGrp.Add oUsr.ADsPath
        oGrp1.Add oUsr.ADsPath
        
        ProcessUser = true
        
    End Function

User avatar
jvierra
Posts: 13502
Joined: Tue May 22, 2007 9:57 am
Contact:

HTA/VBS Noob question

Post by jvierra » Mon Aug 16, 2010 10:50 pm

Note that the remainder of your code to add to groups remains untested as I cannot test this in my domain. This will be a good test of whether this code is an y good as you have posted it. If theuser already exists in these groups you will get a fatal error.


User avatar
thenoob74
Posts: 17
Joined: Tue Aug 10, 2010 1:55 am

HTA/VBS Noob question

Post by thenoob74 » Mon Aug 16, 2010 11:06 pm

Ok, well being this is working right now couldn't I create a case or an if statement to say IF IT user use this ELSE if Standard user use this? If I can get that working then I can move on to the next part of this script and hopefully be out of your hair. I really appreciate your help/guidance.

User avatar
thenoob74
Posts: 17
Joined: Tue Aug 10, 2010 1:55 am

HTA/VBS Noob question

Post by thenoob74 » Mon Aug 16, 2010 11:40 pm

Ok when I run that I get the following: C:Documents and SettingsusernameDesktoptest2.vbs(14, 9) (null): An invalid dn syntax has been specified.

User avatar
thenoob74
Posts: 17
Joined: Tue Aug 10, 2010 1:55 am

HTA/VBS Noob question

Post by thenoob74 » Tue Aug 17, 2010 12:15 am

What I am failing to see here is the point of all this when it's working already. Please explain why I need to use this vs what I am currently using. I have much more to do with this script and am running out of time, it seems like were real close as it is working, but I just need to be able to chose LDAP paths for an IT user and a STD user. Currently I feel like I'm running in circles. The local group is working fine with the WinNt method. The DN I failed to tell you about is not any different, I just plugged in my domain name and ran it. The result is what I posted.

User avatar
jvierra
Posts: 13502
Joined: Tue May 22, 2007 9:57 am
Contact:

HTA/VBS Noob question

Post by jvierra » Tue Aug 17, 2010 1:46 am

I was jus ttrying to figure out what you were trying to add to the local groups. It looks like you want to add the user to PowerUsers but you are adding Domain Users to Power Users. I don't see why you would want to add all 'Domain Users' to the local 'Power Users' group. If you want to add the user to the local Power Users group you must switch to the WinNT version of the user object. YOu need to use the samAcc**tName along with the NTDomain name to create a domain user WinNT aDSPath.

WinNT://./<ntdomain>/<samAccountName>



User avatar
thenoob74
Posts: 17
Joined: Tue Aug 10, 2010 1:55 am

HTA/VBS Noob question

Post by thenoob74 » Tue Aug 17, 2010 2:37 am

Yes the local groups needs to have domain users, that's just the decision were going with, doesn't make sense to me either but this is what they wanted. So for the local Power Users group and Backup Operators group they want to see Domain Users get added there. Then the user him self who is getting TSM installed needs to be added to the domain group called TSM_Backup_users. That part works just fine though and is giving me the desired result. The only piece I'm missing is how I can tell the code to use the IT OU LDAP path when I select IT User from the form and have the Standard OU LDAP path run when I select Standard User. If I had that I can move on to the next piece. I've seen that article from the scripting guys already and used some of the examples.

User avatar
thenoob74
Posts: 17
Joined: Tue Aug 10, 2010 1:55 am

HTA/VBS Noob question

Post by thenoob74 » Tue Aug 17, 2010 4:26 am

Thank you again for your help!

Locked