Aen Posted August 21, 2008 Share Posted August 21, 2008 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 ExplicitDim objShell, objNetwork, ObjGroupDictDim drFinance, drFOutlook, drTestDim sgFinance, sgFinance2, sgFOutlook, sgFOutlook2, sgTestDim shFinance, shFOutlook, shTestDim strDomain, strUser, strAdsPathSet objNetwork = WScript.CreateObject("Wscript.Network")strDomain = objNetwork.UserDomainstrUser = objNetwork.UserNamestrAdsPath = strDomain & "\" & strUserSet objShell = CreateObject("WScript.Shell")Set objNetwork = CreateObject("WScript.Network")'Drive lettersdrFinance = "F:"drFOutlook = "G:"drTest = "Z:"'Security GroupssgFinance = "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) thenobjNetwork.RemoveNetworkDrive drTest, 1, truewscript.Sleep 10000objNetwork.MapNetworkDrive drTest, shTestEnd Ifif isMember(sgFinance) thenobjNetwork.RemoveNetworkDrive drFinance, 1, truewscript.Sleep 10000objNetwork.MapNetworkDrive drTest, shFinanceEnd Ifif isMember(sgFinance2) thenobjNetwork.RemoveNetworkDrive drFinance, 1, truewscript.Sleep 10000objNetwork.MapNetworkDrive drTest, shFinanceEnd Ifif isMember(sgFOutlook) thenobjNetwork.RemoveNetworkDrive drFOutlook, 1, truewscript.Sleep 10000objNetwork.MapNetworkDrive drTest, shFOutlookEnd Ifif isMember(sgFOutlook2) thenobjNetwork.RemoveNetworkDrive drFOutlook, 1, truewscript.Sleep 10000objNetwork.MapNetworkDrive drTest, shFOutlookEnd If'========================================================================='FUNCTIONS'=========================================================================Set objNetwork = NothingSet objShell = NothingWscript.QuitFunction 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 IfEnd Functionright 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 Link to comment Share on other sites More sharing options...
Yzöwl Posted August 21, 2008 Share Posted August 21, 2008 You haven't defined 'objRootLDAP', and even if you had you have Option Explicit turned on, which means you must DIM the variable too before using it. Link to comment Share on other sites More sharing options...
Aen Posted August 21, 2008 Author Share Posted August 21, 2008 You haven't defined 'objRootLDAP', and even if you had you have Option Explicit turned on, which means you must DIM the variable too before using it.I have it DIM'd a few lines up from thatDim oDict, oUser, oGroup, strDNSDomain, objRootLDAPdo i need to do something else to it? Link to comment Share on other sites More sharing options...
Yzöwl Posted August 21, 2008 Share Posted August 21, 2008 Sorry I missed that, I get used to putting all that stuff together in one place!That said, you still haven't defined the objRootLDAP variable:objRootLDAP = <whatever> Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now