Skip to main content
openLDAP

Manage openLDAP users with VB Scripts

By November 25, 2013September 12th, 2022No Comments

Yes Windows and Linux and co-exist! Here we look at using VBScript and ADSI to manage entries in our openLDAP SUSE Server. When Microsoft brought out their Active Directory with Windows 2000 they also developed the ADSI interface that we can use with VBScript to access LDAP object. The Active Directory is LDAP as is, of course, openLDAP. Come on a VBScript course though and you will look at scripting to the Ad but most courses will leave out access to other Directories which is where I like to fill in the gaps. Often, although you may have a Linux LDAP server, desktops are still commonly Windows so we cannot ignore this as a client platform. It only makes sense that we use code that comes with our client platform to access and manage the Directory. In this video, below the script, we look at scripting to create users in our opeLDAP Directory, a sample script is shown below.

Dim obj,usr,fname,lname, uidNo
Dim password, serverName,container, AdminUsrName,user

servername = "192.168.0.100" 'ip address of your ldap server
AdminUsrName = "cn=admin,dc=acme,dc=com" ' your LDAP rootdn
password = "novell" 'your ldap rootpw
container = "ou=people,dc=acme,dc=com" ' where you want to create users

'--bind to the server
Set dso = GetObject("LDAP:")
Set cont = dso.OpenDSObject("LDAP://" & serverName & "/" & container,AdminUsrName,password,0)
fname = inputbox ("FirstName") ' ie Fred
lname = inputbox ("LastName") ' ie Bloggs
uidNo =InputBox ("UID Number")
user = left(fname,1) & lname

ADsPath = "LDAP://" & serverName & "/" & container
Set usr = cont.Create("inetOrgperson", "cn=" & fname & " " & lname)
usr.PutEx 3, "ObjectClass", Array("posixAccount","inetOrgperson")
usr.Put "uid", User
usr.Put "sn", lname
usr.put "cn", fname & " " & lname
usr.put "displayName", fname & " " & lname
usr.put "givenName", fname
usr.put "gidNumber",100
usr.put "uidNumber",uidNo   
usr.put "homeDirectory", "/home/" & user
usr.put "loginShell", "/bin/bash"
usr.put "userPassword","{SSHA}ju90lOCl7+aAEu5LX4AJOD5rxFZiEg6G" 'password
usr.SetInfo