ADSI & Smartsite Configuration

Release 1.1 - ...

Configuration ADSI Connection

The first step to get a working ADSI configuration which can be used within Smartsite is to define a new connectionstring in smartsite.data.config. Make sure the used credentials have read access on the active directory:

XML CopyCode image Copy Code
    <databases>
      <database id="MyADSI">
        <connectionstring providername="System.Data.OleDb">Provider=ADSDSOObject;User ID=smartsite\username;Password=xxxxxxxxxx;</connectionstring>
      </database>  
    </databases>


The next step is to add the id of the new connectionstring (MyADSI) to the securityprofiles used in smartsite.security.config:

XML CopyCode image Copy Code
    <securityprofiles>
      <profile id="Smartsite Site Guest" userroles="GUEST,*">
        <database ref="DB_EmptySix,MyADSI" />
      </profile>
      <profile id="Smartsite Site Visitor" userroles="VISITOR">
        <database ref="DB_EmptySix,MyADSI" />
      </profile>
      <profile id="Smartsite Site User" userroles="CONTENTEDITOR,CONTENTMANAGER">
        <database ref="DB_EmptySix,MyADSI" />
      </profile>
      <profile id="Smartsite Site Administrator" userroles="ADMINISTRATOR">
        <database ref="DB_EmptySix,MyADSI" />
      </profile>
    </securityprofiles>


This connectionstring can now be called from within Smartsite, for example using the macro sqlquery. One limitation is that you can only use the ADSI SQL Dialect for requesting data from the configured Active Directory. More information about ADSI SQL Dialect: http://msdn.microsoft.com/en-us/library/aa746494(VS.85).aspx.

Example se:sqlquery with ADSI SQL:

Smartsite SXML CopyCode image Copy Code
<se:sqlquery connection="MyADSI" save="adsi" resulttype="datatable">
   <se:parameters>
       <se:parameter name="sql">
              SELECT cn,sAMAccountName
              FROM 'LDAP://CN=Users,DC=SMARTSITE,DC=LAN' 
              WHERE userPrincipalName='*'
              AND userAccountControl = 66048      
              AND objectCategory='person'
              AND objectClass='user' 
             ORDER BY CN   
       </se:parameter>
    </se:parameters>
</se:sqlquery>
<se:format inputdata="adsi" whitespace="simpleformat">
    <se:parameters>
        <se:parameter name="format">
          <se:rowformat>
           <tr>
            <td title="CN">{this.field(cn, default='')}</a></td>           
            <td title="department">{this.field(sAMAccountName, default='')}</td>
           </tr>
          </se:rowformat>
         </se:parameter>
         <se:parameter name="resultformat">
          <table> 
           <tr>
            <th>Name</th>
            <th>Loginname</th>
           </tr>
          {this.result()}
          </table>
         </se:parameter>  
         <se:parameter name="default">No data.</se:parameter>
    </se:parameters>
</se:format>

 

You can find a more extended example of an ADSI implementation here!