Archive for the 'Scripting' Category

VBScript - Check if current user is a member of a certain group

I found some code to do this out on the net the other day. I’ve modified it a little, and added the part that checks environment variables.

It probably isn’t too efficient, as it creates a new object and then kills it every time the function is called, but it’s fine for my purposes.

‘Error Handling
On Error Resume Next

‘Calls the isMember function with the specified group to see if the current user
‘ is a member of that group.
If isMember(”TypeGroupNameHere”) = “False” Then
       ‘do something
    Else
       ‘do something else
End If

‘ *****************************************************
‘This function checks to see if the passed group name contains the current
‘ user as a member. Returns True or False
Function IsMember(groupName)
    If IsEmpty(groupListD) then
        Set groupListD = CreateObject(”Scripting.Dictionary”)
        groupListD.CompareMode = TextCompare
        ADSPath = EnvString(”userdomain”) & “/” & EnvString(”username”)
        Set userPath = GetObject(”WinNT://” & ADSPath & “,user”)
        For Each listGroup in userPath.Groups
            groupListD.Add listGroup.Name, “-”
        Next
    End if
    IsMember = CBool(groupListD.Exists(groupName))
End Function
‘ *****************************************************

‘ *****************************************************
‘This function returns a particular environment variable’s value.
‘ for example, if you use EnvString(”username”), it would return
‘ the value of %username%.
Function EnvString(variable)
    set objShell = WScript.CreateObject( “WScript.Shell” )
    variable = “%” & variable & “%”
    EnvString = objShell.ExpandEnvironmentStrings(variable)    
    Set objShell = Nothing    
End Function
‘ *****************************************************

Share/Save/Bookmark

Windows XP Print-Mapping Automation

Found a useful feature in Windows XP the other week when stuffing around with print-mapping scripts. Instead of using the old con2prt feature to connect to printers, you can use Windows’ inbuilt printing APIs to map printers, add new drivers from INF files, remove printer mappings, remove drivers, and much more.

The main reason I like this over the old con2prt.exe is that you can remove individual mappings to printers - you don’t have to remove all the mapped printers at once with a ‘con2prt /f’ if you don’t want to.
Continue reading ‘Windows XP Print-Mapping Automation’

Share/Save/Bookmark

Microsoft Identity Integration Feature Pack (IIFP)

When looking for a solution on how to synchronise our Exchange GALs between two seperate forests, I came across this Microsoft feature pack - which is freely available to download from their website.

What IIFP does according to Microsoft: “Identity Integration Feature Pack 1a for Microsoft® Windows Serverâ„¢ Active Directory® manages identities and coordinates user details across Microsoft Active Directory, Active Directory Application Mode (ADAM), Microsoft Exchange 2000 Server, and Exchange Server 2003 implementations. ”

The download link:
IIFP Download

There’s only one catch: you need an enterprise version of Windows 2003 Server to be able to install the feature pack. A little birdie tells me that if you use Orca from the Windows 2003 Server SDK, you can modify the installation requirements to get it working on a non-enterprise version of Windows 2003 Server.

IIFP on Windows 2003 Server Std.

Here’s a tutorial from MSExchange.org on GAL synchronisation:
http://www.msexchange.org/pages/article_p.asp?id=668

I couldn’t end up getting it to work because of domain naming issues between the two domains (one is named as a parent of the other one without actually being the AD parent domain), but it looks like it could be a very useful tool.

Share/Save/Bookmark