Jump to content

Aen

Member
  • Posts

    18
  • Joined

  • Last visited

  • Donations

    0.00 USD 
  • Country

    United States

Posts posted by Aen

  1. Hi, I dont know vbscript but you can get more info with the use of a soft like LDP.exe or ldap browser.

    But by experience when you make a query you must first indicate the base DN, domain and account to connect. Be carefull the base DN is different if you query a Windows AD, Netware, Lotus Domino. try first to query a windows AD and you'll see the different objects and atttributes.

    Hope this will help you.

    i can find the DN by going through ADSIedit.msc. But, i am making a script that when a user will enter in a username and employee number, it will change the custom employee ID field. We dont really want to give them access to ADSIedit because it can be very dangerous. We are only using Windows AD.

  2. Writing a script that basically does this:

    1. Ask user for a username

    2. Ask user for employee number

    3. script verifies if it is real username

    - if it is, continues

    - if not, it stops script

    4. (step i need help with) - Query AD through LDAP and pull DN

    5. Add employee number to 2 different fields in AD (employeeID, employeeNumber)

    Real simple script.. but having some issues getting the DN from AD.

    *DN = distinguishedName

    Here is what i got:

    Set objFile = CreateObject("Scripting.FileSystemObject")
    Set objNetName = CreateObject("WScript.NetWork")

    DIM strEmpID
    Name = GetUserName()
    EmployeeID = GetEmployeeID()
    UserExists = CheckUser(Name)

    If UserExists = TRUE then
    msgbox strEmpID
    msgbox Name
    Call LoadEmployeeID
    Else
    Msgbox "User does not exist, try again."
    wscript.quit(0)
    End If

    '===========================
    Function LoadEmployeeID()
    Set objUser = GetObject

    objUser.Put "employeeNumber", strEmpID
    'objUser.Put "employeeID", EmployeeID
    objUser.SetInfo

    End Function
    '===========================
    Function GetEmployeeID()
    EmployeeID = Inputbox ("Please enter in 5 digit employee number")
    strEmpID = EmployeeID
    End Function

    '=======================================
    Function GetUserName()

    i = 0
    UserName = InputBox ("Ex. Firstname.LastName ", " Please Enter User Name")

    Do While Instr(UserName, ".") = 0 and i <= 5

    Username = InputBox ("Ex. Firstname.LastName ", " Please Enter User Name")

    i=i+1

    Loop

    If Instr(UserName, ".") = 0 Then
    WScript.Quit(0)
    Else

    GetUserName = Trim(UserName)
    End If
    End Function
    '===========================================
    Function CheckUser(strUserName)

    dtStart = TimeValue(Now())
    Set objConnection = CreateObject("ADODB.Connection")
    objConnection.Open "Provider=ADsDSOObject;"

    Set objCommand = CreateObject("ADODB.Command")
    objCommand.ActiveConnection = objConnection

    objCommand.CommandText = _
    "<LDAP:/*removed*t>;(&(objectCategory=User)" & _
    "(samAccountName=" & strUserName & "));samAccountName;distinguishedName;subtree"

    Set objRecordSet = objCommand.Execute

    If objRecordset.RecordCount = 0 Then
    'WScript.Echo "sAMAccountName: " & strUserName & " does not exist."
    CheckUser = FALSE
    Else
    objRecordset.MoveFirst
    Do while Not objRecordset.EOF
    wscript.echo objRecordset("samAccountName") & " | " & objRecordset("distinguishedName")
    objRecordset.MoveNext
    Loop
    'WScript.Echo strUserName & " exists."
    CheckUser = TRUE
    End If

    objConnection.Close

    End Function
    '====================================================

    Can anyone please give some advice or code that can help?

    I think if i can just pull the DN from LDAP query and put that into a variable..i can finish the rest.

  3. I am trying to make a logon VBScript. The purpose of the script is if a user is part of a AD Security Group, then it will unmap a drive letter, and then map a drive letter. I am having issues getting the part of finding if the user is part of that SG.

    Now i will admit, i have no idea what i am doing, and probably not the best way of doing it. Here is what i got so far:

    Option Explicit
    Dim objShell, objNetwork, ObjGroupDict
    Dim drFinance, drFOutlook, drTest
    Dim sgFinance, sgFinance2, sgFOutlook, sgFOutlook2, sgTest
    Dim shFinance, shFOutlook, shTest
    Dim strDomain, strUser, strAdsPath
    Set objNetwork = WScript.CreateObject("Wscript.Network")
    strDomain = objNetwork.UserDomain
    strUser = objNetwork.UserName
    strAdsPath = strDomain & "\" & strUser
    Set objShell = CreateObject("WScript.Shell")
    Set objNetwork = CreateObject("WScript.Network")

    'Drive letters
    drFinance = "F:"
    drFOutlook = "G:"
    drTest = "Z:"

    'Security Groups
    sgFinance = "CFOOrganization - Finance - M"
    sgFinance2 = "CFOOrganization - Finance - R"
    sgFOutlook = "CFOOrganization - FinanceOutlook - M"
    sgFOutlook2 = "CFOOrganization - FinanceOutlook - R"
    sgTest = "testdrivemapping"

    'Shares:
    shFinance = "\\none\data\CFOOrganization\Finance"
    shFOutlook = "\\none\data\CFOOrganization\FinanceOutlook"
    shTest = "\\none\data"


    if isMember(sgTest) then
    objNetwork.RemoveNetworkDrive drTest, 1, true
    wscript.Sleep 10000
    objNetwork.MapNetworkDrive drTest, shTest
    End If

    if isMember(sgFinance) then
    objNetwork.RemoveNetworkDrive drFinance, 1, true
    wscript.Sleep 10000
    objNetwork.MapNetworkDrive drTest, shFinance
    End If

    if isMember(sgFinance2) then
    objNetwork.RemoveNetworkDrive drFinance, 1, true
    wscript.Sleep 10000
    objNetwork.MapNetworkDrive drTest, shFinance
    End If

    if isMember(sgFOutlook) then
    objNetwork.RemoveNetworkDrive drFOutlook, 1, true
    wscript.Sleep 10000
    objNetwork.MapNetworkDrive drTest, shFOutlook
    End If

    if isMember(sgFOutlook2) then
    objNetwork.RemoveNetworkDrive drFOutlook, 1, true
    wscript.Sleep 10000
    objNetwork.MapNetworkDrive drTest, shFOutlook
    End If



    '=========================================================================
    'FUNCTIONS
    '=========================================================================

    Set objNetwork = Nothing
    Set objShell = Nothing

    Wscript.Quit

    Function IsMember(sGroup)
    Dim oDict, oUser, oGroup, strDNSDomain, objRootLDAP

    If IsEmpty(oDict) Then
    Set oDict = CreateObject("Scripting.Dictionary")
    set strDNSDomain = objRootLDAP.Get("DefaultNamingContext")
    oDict.CompareMode = vbTextCompare

    'Location in AD: none.ad.none.net/None Domain Users/Standard Accounts/Americas
    Set oUser = GetObject("LDAP://cn=Americas, cn=Standard Aaccounts, cn=None Domain users," & strDNSDomain)
    For Each oGroup In oUser.Groups
    oDict.Add oGroup.Name, "-"
    Next
    Set oUser = Nothing
    End If

    End Function

    right now when i run it i get:

    C:\mapdrivetest.vbs(74, 3) Microsoft VBScript runtime error: Object required: 'objRootLDAP'

    which is this line:

    set strDNSDomain = objRootLDAP.Get("DefaultNamingContext")

    I just have no idea what i am doing wrong. I am not sure if i am doing this right at all. Can you point me to the right direction?

    --Aen

  4. I don't like messing with the zones, so when I have installs running from network locations, I use a self-extracting 7zip package. That allows you to run the install from the network, but the install itself is run on the local system, and then deleted after the fact.

    we are going to be using MSI files to later to deploy with Altiris once that gets all the way up and going. I will check out 7zip's self extracting though. That may help on a few things.

  5. then kicks off the install then right that second it turns back off that key

    Then it's an issue with WSH or such, because it's supposed to wait, and it does wait then I try it (with another process at least). Or maybe msiexec spawns another process and terminates almost instantly, and then the script continues, in which case a short delay would work (or waiting for the install to be finished)...

    its kinda weird. I just tried with a different MSI install and it worked the way its supposed to. I am going to rebuild it.

    Thanks again for your insight and help :)

  6. Ok, this should get you mostly there then:

    Const cPath1806 = "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3\1806"
    Const cCurrentLevel = "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3\CurrentLevel"

    Set objShell = CreateObject("WScript.Shell")

    'read old values
    sPath1806 = objShell.RegRead(cPath1806)
    sCurrentLevel = objShell.RegRead(cCurrentLevel)

    'set temp values
    objShell.RegWrite cPath1806, 0, "REG_DWORD"
    objShell.RegWrite cCurrentLevel, 0, "REG_DWORD"

    'run program
    objShell.Run "msiexec /i \\Server\e$\file.msi /qb", 1, True

    'restore old values
    objShell.RegWrite cPath1806, sPath1806, "REG_DWORD"
    objShell.RegWrite cCurrentLevel, sCurrentLevel, "REG_DWORD"

    I haven't actually tested running an installer from a network share mind you, so you might have to play with that part (setting reg values is tested though). I put in some comments, so it should be fairly simple to understand.

    Thanks! I got to look at why it says my MSI is not a valid windows installation package.

  7. I could write that script in a couple minutes (literally). But I'm not sure what you're doing with them reg keys, in your first post you say you remove them, yet you were using reg add (which adds keys/valus), and now you're mentioning RegRead (which reads) -- nothing that deletes keys anywhere. And I don't normally mess with the IE zones too much, so not 100% sure what has to be set to what to not get those warnings on your local intranet.

    If you said what it has to do in plain terms, i.e. "delete value named xyz in HKLM\Software\whatever" or "set the value named xyz to 123 at HKLM\Software\whatever" or such (and know for a fact that would work), then it would be trivial to write in just about any scripting language. It's hard writing a script for someone else when you're not even sure what it has to do.

    Sorry, i got so many things going on at once. What it is really doing is changing 2 different registry values so windows security will no longer pop up. Then install the application. After the application installs (which is my issue, it starts it then goes to the next line) then puts the value back to what it was orginally.

    When installing the application from a remote server it uses the internet settings for files, so that is why i am trying to disable those.

  8. 2 things:

    WScript.Shell has methods such as RegRead, RegWrite, and RegDelete. See the docs on MSDN here. It's very simple to use, and works better. There's no need at all to use reg.exe for this (and no need for the sleep "hack" either). There's plenty of examples around if you google for it, or you can check the scripting guy's columns, or the scripting center, or various community sites, tutorials and what not. There's no shortage of resources about scripting out there.

    And also, why not use silent switches on the msi installer too?

    Edit: and to start a MSI installer, I wouldn't exactly use "cmd" either, but rather msiexec.

    heh, i have been googling a LOT last few days. And i have been just piecing together what i have found. Problem is, i dont know the best way to script this stuff. I just do a search and try to piece things together. I get tossed a project and they say "use vbscript" and i am trying to work on it best i can.

    When i try to do the silent commands for msi files, it still comes up with windows security asking if i want to run the file. The whole project has to be done without human intervention and work 100% without someone touching it.

    Using the regread (that you just mentioned) i can change my commands to do that, but when i launch the msi app, it still asks for that security code and still have the same issue.

  9. I am doing a unattended install through Altiris. Boss wishes to have all of the applications installed through VBScript. But after the unattended install, Windows Security pops up and asks "do you really want to install....." And you need to click Run. So i found some registry keys to disable that feature, then run the install of the app, then adds the keys again to re-enable it. My problem is, is that the way i got my VBScript it basically runs the commands through a command prompt. so, it does this:

    Remove key

    Remove Key

    install app

    add key

    add key

    It does not wait for the app to finish installing, once it sends the command, it goes to the next line. Putting in a sleep command can waste a lot of time and i just need to figure out how for the script to know when the application is finished, it will add the keys back. I am a newb with VBScript and my coworkers just say "figure it out yourself" and i have been wasting my day away trying to figure this out. Boss is very anal and requires it a certain way and wants it so when the applications are finished, it will add the key back and not just use a wscript.sleep command.

    here is my script so far. Any help would be great. I will take advice or if you want to write it lol. *shrugs*

    Option Explicit
    Dim objShell
    Set objShell = CreateObject("Wscript.Shell")
    objShell.Run "reg add ""HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3"" /v ""1806"" /t REG_DWORD /d 0 /f", 1, True
    objShell.Run "reg add ""HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3"" /v ""CurrentLevel"" /t REG_DWORD /d 0 /f", 1, True
    WScript.Sleep(10000)
    objShell.Run "cmd /c start \\Server\e$\file.msi", 1, True
    WScript.Sleep(10000)
    objShell.Run "reg add ""HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3"" /v ""1806"" /t REG_DWORD /d 1 /f", 1, True
    objShell.Run "reg add ""HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3"" /v ""CurrentLevel"" /t REG_DWORD /d 12000 /f", 1, True
    WScript.Quit

  10. I just inherited a windows 2003 server that has Word 2002 and Excel 2002 installed on it. When i try to remove it from the server it is asking for the source disks. looking for the excel.msi and word.msi files. I have a copy of office xp but it can not locate those files and i can not get rid of those prgms. Server they gave my group has a 4 gig C drive and its killing me on space. Need to get it usable for a month till our new server comes in for replacement.

    Anyone know how i can fix this?

  11. We had done the same thing here last week. we used the print migrater to get all of the printers off of one server and use it again on the new system.

    The file share are a little different. First what you need to do is do a robocopy of all of your old data to your new server. Once it is synced up, disjoin the server from the domain and change the name. Join it back to the domain and do the robocopy again so all files that were in use are no longer in use and no user will connect to it again while you are trying to do this. Next add in a DNS record for the old server's name to the new server. This way DFS will still work and anyone using the old printserver/fileserver will be able to still use there shortcuts and network mappings.

    Shares were the tricky part. We used Hyena to pull out Sharename, Sharepath, Description, Type of share into a CVS document. Then pulled out all of the default system shares so none of the shares are the same. After that i wrote a script that will create the shares:

    This was ran from DOS as cscript

    'Define Constants and Global Variables
    Const FILE_SHARE = 0
    Const MAXIMUM_CONNECTIONS = Null
    Const ForReading = 1
    Const TristateTrue = -1
    strComputer = "SERVER NAME"

    'Instantiate WMI objects to create shares
    Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    Set objNewShare = objWMIService.Get("Win32_Share")

    'Instantiate File System Object and open input file
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    'add the path where your txt document is at
    Set objTextFile = objFSO.OpenTextFile ("D:\Migration\Users-Standard.txt", ForReading, False, TristateTrue)

    'Loop through input file
    Do Until objTextFile.AtEndOfStream
    CreateShare(objTextFile.Readline)
    Loop

    'arrShares(0) = share name
    'arrShares(1) = share path
    'arrShares(2) = Description
    'arrShares(3) = type of share

    Sub CreateShare(txtLine)
    arrShares = Split(txtLine, ",")
    Wscript.Echo """" & arrShares(1) & """" &","& arrShares(0) &","& arrShares(3) &","& MAXIMUM_CONNECTIONS &","& arrShares(2)
    errReturn = objNewShare.Create (arrShares(1), arrShares(0), arrShares(3), MAXIMUM_CONNECTIONS, arrShares(2))
    'Wscript.Echo errReturn
    End Sub

    Here is a sample of the txt file we used to create the shares:

    NAME1$,G:\Users\Standard\NAME1,,0
    NAME2$,G:\Users\Standard\NAME2,,0

    Robocopy

    What i did was create a batch file with all of the robocopy commands. We are taking down 3 file servers into 1 with a single drive. Each server had 2 drives on it. So i just set a schedule task to run this robocopy nightly just to make sure we get all of the data until we are ready.

    sample:

    robocopy.exe "\\Sourceserver\f$" "\\Destserver\f$\Sourceserver_FDrive" /S /E /ZB /COPYALL /R:2 /W:5 /PURGE /XD \\Sourceserver\F$\DFSROOT\ /log:C:\robocopy\sourceserver-f.log

    Robocopy.exe [source location] [dest location]

    /S - Copy subfolders

    /E - Copy subs including empty

    /Z - copy files in restartable mode (survive network glitch).

    /B - copy files in Backup mode.

    /COPYALL - copy all file info

    /R:2 - 2 retries

    /W:5 - Wait 5seconds between tries

    /PURGE - delete dest files/folders that no longer exist in source.

    /XD \\[source server & location] - Do not copy a selected folder. I did this because DFSROOT would not copy and error out. It would take HOURS to sync that with the /r & /w

    /log [location] - output a log to see what failed and what copied.

    Hope that helps some. Good luck :P

  12. So here goes my problems. We have numerous DFS servers. Somehow some users are able to add new folders directly into the middle of DFS virtual paths. They are able to create them where they should not be able to. They do not create it by the DFS console and create a DFS link that way. Nor do they create a folder in a real folder. For example:

    \\domain\data\Operations\Projects\Project1

    \\Virtual\Virtual\Virtual\Virtual\RealFolder

    They are able to create a folder \\domain\data\operations\NewFolder\ They just right click in the DFS path and create a new folder and give it permissions.

    Where do i go to stop this? I thought no one could do that? I found the data randomly through at some of the DFSroot folders.

    I checked the DFSroots and DFS Admins is part of it that has modify access. All users by a few domain admins are in that group.

    What else do you guys think i should look?

  13. Ok, so for the Sigmatel HD Audio, you have to install the UAA (Universal Audio Architecture) Drivers first. Now, unfortunately, you have to contact Microsoft to download them.

    It's the KB888111 article - (http://support.microsoft.com/kb/888111). Conact them, slip stream this goodness and away you go.

    Now, as for your other queries, I'm afraid I can't help yet.

    The problem i see is that it will not automatically install. You actually have to click on next and let it search. it will find it and then install it. Anyone get this to work to have it install automatically? I have this same problem trying to install the soundmax audio drivers on an Optiplex 745. Really annoying.

×
×
  • Create New...