Ok, this is complicated to explain.
Say, for example, that you want to have a link on a website, that a user can click on, to gain access to their Home Directory (which is retrieved from the Active Directory field).
Ok, kind of a specific need, I know.
What do you need to do this:
1. Create a linked server connection, called ADSI, with the following :
sp_addlinkedserver ‘ADSI’, ‘Active Directory Service Interfaces’, ‘ADSDSOObject’, ‘adsdatasource’
2. Create a website in IIS, ensure that authentication is Windows Integrated, and not Anonymous.
3. Create an ASPX page, and give it a FormView (or data enabled tool).
4. Give it a SQL Server Data source, with a query similar to the one below:
FROM OpenQuery( ADSI,’LDAP://AD_DETAILS;
homeDirectory, sAMAccountName, distinguishedName’)
where sAMAccountName in (select SUBSTRING ( SYSTEM_USER , CHARINDEX(‘\’,SYSTEM_USER)+1, len(SYSTEM_USER)-CHARINDEX(‘\’,SYSTEM_USER)) )
This query will return the home directory, from ADSI Linked Server, for the current user.
5. All you then need to do is bind the returned field to a button. You can do this with the following:
<asp:HyperLink ID=”HyperLink1″ runat=”server” NavigateUrl=’<%# Bind(“homeDirectory”) %>‘> mylink is here</asp:HyperLink>