Dwarfsoft [GPA]

Scripting for Novell

by on Sep.09, 2007, under LDAP, Novell, Scripting, Work

Print This Post Print This Post

I have had a bit of time to try some new scripting with Novell, mainly for use with my Security Auditing Tool. Some of this information I have not been able to find out on the ‘net and as such decided to post up here so that others may benefit from using this information. Basically this lot of scripting will cover getting the Server Name that hosts a volume within a cluster. Each of the Volumes in the Cluster has its own Server object in eDirectory such that the server name is SITE-CL1_SC_DATA5_SERVER or similar. The first thing we need to do is translate the Drive Letter to a Server and Volume Name:

Function GetServerFromDrive(DriveLetter)
   Set fso = WScript.CreateObject("Scripting.FileSystemObject")
   Set Drives = FileSystemObject.Drives 
   For Each DiskDrive in Drives
      If DiskDrive.DriveLetter = Drive Then
         ShareParts = Split(DiskDrive.ShareName,"\")
         Server = ShareParts(2)
         Volume = ShareParts(3)
      End If
   If IsEmpty(Server) Or IsEmpty(Volume) Then
      'This is not a network Drive. Exiting.
      GetServerFromDrive = ""
      GetServerFromDrive = Server
   End If
End Function

This function can be called to retrieve the servername that is associated with the mapped network drive. If the sharename does not include both a Server Name and a Volume Name part then an empty string is returned.

Server = GetServerFromDrive("H")

Now, the server returned by this may not actually be the name of the server that is hosting the volume, but merely a synonym for the server that is hosting the volume. If we want to know exactly which cluster server has the role of the host for this volume then we need to get into some LDAP querying.

Function GetVolumeClusterServerPath(ServerName)
   On Error Resume Next
   dim sam, objLDAP, ClusterServer
   GetVolumeClusterServerPath = ""
   Set objLDAP = GetObject("LDAP:")
   Set sam = objLDAP.OpenDSObject("LDAP://" & ServerName & "/RootDSE","", "", 0)
   ClusterServer = sam.Get("dsaName")
   GetVolumeClusterServerPath = ClusterServer
End Function

I’ve used “On Error Resume Next” in this function because in the eDirectory tree that I have been testing against, some machines fail to connect to /RootDSE, and will error out of the script at this point. By requesting dsaName from the RootDSE object, we retrieve the actual name for the cluster server that is hosting the volume. This returns the Full LDAP Path of the Server Object. As we really only need the name itself and not the path we can either split by “,” then split the first element by “=” and get the second element, or we can open the LDAP object and get the cn:

Function GetServerCN(ClusterServerPath)
   dim objLDAP, sam, ServerCN
   GetServerCN = ""
   Set objLDAP = GetObject("LDAP:")
   Set sam = objLDAP.OpenDSObject("LDAP://QLDHEALTH/" & ClusterServerPath,"", "", 0)
   ServerCN = sam.Get("cn")
   GetServerCN = ServerCN
End Function

I’ll probably post up my scripts for listing Security for groups/folders later, just due to there being so few resources around that have Novell eDirectory scripting ideas. I have been using Microsofts LDP to browse the eDirectory tree and determine what information I can extract from eDirectory over LDAP. There will be a few more scripts coming soon.

Cheers, Chris.

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!