Popup window on AD login

Posted on 2012-08-25
Last Modified: 2012-08-26

I have some users using generic accounts that I need to disable in order they use their own personal accounts on a Windows 2008 domain. These generic accounts will be disabled at a future date.

1. Windows style pop up box to appear whenever any of these generic accounts are used to login.
2. The dialog box must require the user to click OK before it is goes away
3. Like to be able to easily control which users (generic accounts) get this message but editing one file with the list of usernames so I can use it with other accounts in the future.

Many thanks.
Question by:inforr
    LVL 65

    Accepted Solution

    Hi, are there generic accounts part of a particular AD group that no one else is in?  You can have a login script popup for only the users in that group.



    Set objNetwork = CreateObject("WScript.Network")
    strGroupToCheck = "Generic Users"
    Set objWinntUser = GetObject("WinNT://" & objNetwork.UserDomain & "/" & strNTLogin & ",user")
    If IsMemberOfGroup(objNetwork.UserDomain, objWinntUser, strGroupToCheck) = True Then
       MsgBox "Your acount will soon be disabled."
    End If
    Function IsMemberOfGroup(strUserDomain, objuser, strGroup) 'the user is a member of a specified group
        IsMemberOfGroup = False
        Dim objGroup
        On Error Resume Next
        Set objGroup = GetObject("WinNT://" & strUserDomain & "/" & strGroup & ",group")
        If Err.Number Then
            IsMemberOfGroup = "Error"
            IsMemberOfGroup = objGroup.IsMember(objuser.adsPath)
            'MsgBox objUser.ADsPath
        End If
    End Function

    Open in new window


    Author Comment

    Hi Rob,

    Thanks for the quick response.

    Good tip about creating a group. I copied the script above, created the groupas needed and saved it as a VBS and updated the Logon scripts section of the GPO.

    When the script runs it is giving an error as follows:
    Script: <Path to script on sysvol>
    Line: 3
    Char: 1
    Error: 0x80005000
    Code: 80005000
    Source: (null)

    This happens on logon or by manually double clicking on the VBS file.

    Any ideas, what may be causing this?

    LVL 65

    Expert Comment

    Oops, change this line:
    Set objWinntUser = GetObject("WinNT://" & objNetwork.UserDomain & "/" & strNTLogin & ",user")

    Open in new window

    to this:
    Set objWinntUser = GetObject("WinNT://" & objNetwork.UserDomain & "/" & objNetwork.Username & ",user")

    Open in new window



    Author Comment

    Perfect - thank you.
    LVL 65

    Expert Comment

    No problem. Thanks for the grade.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    As network administrators; we know how hard it is to track user’s login/logout using security event log (BTW it is harder now in windows 2008 because user name is always “N/A” in the grid), and most of us either get 3rd party tools, or just make our…
    Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  ( Here (http…
    This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
    This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now