Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ; IPNet2ADSite Function ; ; ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; #DefineFunction UDF_IPNet2ADSite(vstrIPNetwork) vstrADSIPath = GetObject("LDAP://rootDSE") vstrConfigurationNC = vstrADSiPath.Get("configurationNamingContext") vstrSitesContainer = StrCat("LDAP://cn=Sites,",vstrConfigurationNC) vobjSitesContainer = GetObject(vstrSitesContainer) ; vstrTest = ObjectTypeGet(vobjSitesContainer) ; Cycle through the list of site objects to find the subnet(s) associated with the site ForEach vobjSite in vobjSitesContainer ; vstrObjClass = dsGetClass(vstrSitesContainer) ; vstrPropertyList = dsGetPropName(vstrSitesContainer,3) ; Retrieve the name of the site vstrSiteName = vobjSite.Name ; Place the site name in the appropriate spot in the fully qualified name for the ; site object vstrFQName = StrReplace(vstrSitesContainer,"LDAP://",StrCat("LDAP://",vstrSiteName,",")) ; If the object is a site object, check its subnet(s) If StrUpper(dsGetClass(vstrFQName)) == "SITE" Then ; Retreive the subnet list vstrSiteObjectBL = dsGetProperty(vstrFQName,"SiteObjectBL") ; Determine how many subnets are associated with this site. vintNetworkCount = ItemCount(vstrSiteObjectBL,@TAB) If vintNetworkCount == 1 Then ; If there's only one sites, separate the IP subnet from the subnet mask ; and fully qualified object name. vstrSubNet = ItemExtract(1,vstrSiteObjectBL,"/") ; If the subnet matches the network you're looking for, return the site name If StrUpper(vstrSubNet) == StrCat("CN=",vstrIPNetwork) Then vstrSiteName = ItemExtract(2,vstrSiteName,"=") Return(vstrSiteName) End If Else ; If there is more than one subnet associated with the site, cycle through the ; subnets and look for a match. For vintNetworkCounter = 1 to vintNetworkCount vstrSubNet = ItemExtract(vintNetworkCounter,vstrSiteObjectBL,@TAB) vstrSubSubNet = ItemExtract(1,vstrSubnet,"/") If StrUpper(ItemExtract(1,vstrSubnet,"/")) == StrCat("CN=",vstrIPNetwork) Then vstrSiteName = ItemExtract(2,vstrSiteName,"=") Return(vstrSiteName) End If Next End If End If Next Return("") #EndFunction ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ; IPNet2SMSSite Function ; ; ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; This fuction expects an IP network or AD Site name as the first element passed ; vstrType is used to dictate whether vstrCriterion is an IP network or AD Site. ; vstrType = 1 IP Network ; vstrtype = 2 AD Site name. #DefineFunction UDF_IPNet2SMSSite(vstrCriterion, vstrType) UDS_InitConstants() Select @TRUE Case vstrType == 1 ; IP network vstrSQLString = StrCat("Select SiteCode from SiteBoundaryIPSubnet where IPSubnet = ",vstrCriterion) Break Case vstrType == 2 ; AD Site vstrSQLString = StrCat("Select SiteCode from dbo.SiteBoundaryADSite where ADSiteName = '", vstrCriterion,"'") Break Case @TRUE UDS_WriteToLog(vstrLogFile,"Error 60 - Invalid data passed to function!",1) IntControl(1000,60,0,0,0) Exit End Select vobjDatabase = ObjectCreate("adodb.connection") vobjDatabase.Open = ("driver={SQL Server};server=hcidalas19;database=sms_dal;trusted_connection=yes") vobjRecordSet = vobjDatabase.Execute(vstrSQLString) vstrSMSSite = vobjRecordSet.GetString() ;Strip out the carriage return by treating it as a delimiter vstrSMSSite = ItemExtract(1,vstrSMSSite,@CR) vobjRecordSet.Close vobjDatabase.Close Return(vstrSMSSite) #EndFunction
Article ID: W17482
File Created: 2009:01:12:08:28:42
Last Updated: 2009:01:12:08:28:42