Connecting to Microsoft Active Directory. To access Microsoft Active Directory from Sisense, you must provide valid Oauth Microsoft Active Directory credentials through a connection string. The connection string is used to authenticate users who connect to the Microsoft Active Directory tables.
- 'GetUserObject() returns an IADs object representing either the LDAP: string
- ' if passed, or the logged-on user otherwise.
- Public Function GetUserObject(Optional ByVal strDN As String = ') As Object
- If strDN > ' Then
- Set GetUserObject = GetObject('LDAP://' & strDN)
- Else
- strDN = 'LDAP://OU=MyBusiness,' & _
- GetObject('LDAP://RootDSE').Get('rootDomainNamingContext')
- Set GetUserObject = ProcessIAD(GetObject(strDN), GetLogonName)
- End If
- End Function
- 'ProcessIAD() is called recursively and returns an object only when it is a user
- ' that matches strUser.
- Private Function ProcessIAD(ByRef iadVar As Object, strUser As String) As Object
- Dim iadWork As Object
- With iadVar
- Select Case IADType(iadVar)
- Case 'User'
- If .sAMAccountName = strUser Then Set ProcessIAD = iadVar
- Exit Function
- Case 'organizationalUnit'
- For Each iadWork In iadVar
- Set ProcessIAD = ProcessIAD(iadWork, strUser)
- If Not ProcessIAD Is Nothing Then Exit Function
- Next iadWork
- End Select
- End With
- End Function
- 'IADType() returns whether the IAD should be treated as a container
- ' (organizationalUnit), a user (user), or simply ignored (group).
- Private Function IADType(iadVar As Object) As String
- Dim varWork As Variant
- With iadVar
- Call .GetInfo
- For Each varWork In .Get('objectClass')
- Select Case varWork
- Case 'user', 'group', 'organizationalUnit'
- IADType = varWork
- Exit For
- End Select
- Next varWork
- End With
- End Function
|