Previous in Contents Next in Contents

Setting Up a New Directory Service

In this example, a new Membership Directory Service is created. The process follows the one used by the new Membership Authentication Service wizard that runs through the Microsoft® Management Console when a new instance is requested. The example listed below is limited to the steps required to configure the basic LDAP service. An example describing the complete process of creating a new Membership Authentication Service instance, including the configuration of the new Active User Objects providers and the Message Builder service, is listed in the examples under Creating a New Membership Service Instance.

The examples shown below in various languages all do the following:

  1. Create the SQL database that the LDAP server uses to persist information. This step uses the SetupStore coclass.

  2. Create a new LDAP service instance, and configure it to use the previously built SQL database created in step 1. This step uses the ldapcfg coclass.

In these examples, the following configuration information is used:

Of course, before proceeding, you need to make sure the SQL Server instance running on host Server1 has an empty database ready to go, and that the login information is correct.

C++

#import “c:\\winnt\system32\\inetsrv\\objcreator.dll” no_namespace
#import “c:\\winnt\\system32\\inetsrv\\setupstore.dll” no_namespace
#import “c:\\Microsoft Site Server\\Bin\\P&M\\ladmin2.dll” no_namespace

main()
{
  IObjCreatorPtr pIObjCreator = new IObjCreatorPtr(_uuidof(ObjCreator));
  _bstr_t ProgId = “MemAdmin.SetupStore”;
  ISetupStorePtr pISetupStore = pIObjCreator->CreateObjAuth(ProgId, L””);

_bstr_t  DBUsername="sa";
_bstr_t   DBPassword="sa";
_bstr_t   DirectorySuperPass="password";
_bstr_t   ServerName = "Server1";
_bstr_t   Database="db1";
_bstr_t   DirectoryName="RealmA";
_bstr_t   DnPrefix="";
BOOL      UseMemSecurity=TRUE;
// set up the tables in the SQL database
try {
   pISetupStore->CreateSQLDB(
                           ServerName,
                           Database,
                           DirectoryName,
                           DBUsername,
                           DBPassword,
                           DirectorySuperPass,
                           UseU2Security
                          );
}
catch ( _com_error Er ) {}

// now define the LDAP server instance

IldapcfgPtr pldap = new IldapcfgPtr(_uuidof(ldapcfg));
pldap->AttachToLocalMachine();
//instance id
_variant_t InstanceId = new _variant_t(3)
pldap->CreateConfig(InstanceId);

// backend db type =1 (SQL)
_variant_t type = new _variant_t((long) 1);
pldap->DBType = type
// database info needed
_bstr_t DBSource = “SomeServer”
pldap->DBSource = DBSource;
_bstr_t DBname = “database_name”
pldap->DBName = DBname;
_bstr_t DBUsername = “sa”;
pldap->DBUsername = DBUsername;
_bstr_t password = “pwd”;
pldap->DBPassword = password;

// set the networking stuff
_variant_t Port = new _variant_t((long) 9000);
_variant_t SSLPort = new _variant_t((long) 9001);

pldap->Port = Port;
pldap->SecurePort = SSLPort;

pldap->SaveConfig();
pldap->StartServer(InstanceID);

The LDAP service instance is now configured and should be running.

VBScript

 ‘// Here we create or admin object SetupStore.  Note that since
‘// we are going to run the CreateSQLDB method, we need 
‘//  the full capabilities of the SetupStore coclass, so we
‘// use the ObjCreator coclass to create the instance.  This
‘// is required.

Set ObjCreator = CreateObject("ObjCreator.Objcreator.1")
Set DSConf = ObjCr.CreateObjAuth("MemAdmin.DSConfig.1")

DBUsername="sa"
DBPassword="sa"
DirectorySuperPass="password"
ServerName = "Server1"
Database="db1"
DirectoryName="RealmA"
DnPrefix=""
UseMemSecurity=True

call DSConf.CreateSQLDB(ServerName,Database,DirectoryName,DBUsername,DBPassword,DirectorySuperPass,UseU2Security)

set o = createobject("MemAdmin.ldapconfig.1")
o.attachtolocalmachine

virtserver = 3
o.createconfig virtserver 

o.DBType = 1
o.DBSource = ServerName
o.DBName = Database
o.DBUsername=DBUsername
o.DBPassword=DBPassword

wscript.echo "calling validatedb"
o.validatedatabase 1, ServerName ,Database,DBusername,DBPassword,1

Port = 9006
SecurePort = 9056
o.Port = Port
o.SecurePort = SecurePort

o.Saveconfig

o.startserver virtserver

© 1997-2000 Microsoft Corporation. All rights reserved.