查询活动目录-当前用户 [英] Query Active directory - Current User

查看:54
本文介绍了查询活动目录-当前用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我是C#Sharp上的 完整 Newbee,可以说是一个真正的新生,我肯定可以使用一些帮助.

我设法使用Visual C#的Webforms创建了一个非常基本的网站.我正在使用Visual Studio 2010和.NET 3.5.

我为此网站创建了一个母版页,所有的Web表单都将基于该母版页.在每个Web表单上,我都希望显示将访问我的网站的用户名和电子邮件地址.

但是我不知道如何从我的Masterpage.master
执行AD查询.
下面是我为此创造的.
-那么我应该在哪里查询广告?
-代码看起来如何?
-我可以使用我的工具箱吗?
-用户名应显示在USer_Name(请参见下面的代码)
-E-MailAddress应该显示在E-Mail_adres(请参见下面的代码)

Hi,

I''m a complete Newbee on C# sharp, a real freshman so to speak and I could definitely use some help.

I''ve Managed to create a very basic website, using Webforms with Visual C#. I''m using Visual Studio 2010 and .NET 3.5.

For this site I created a Master page, on which all my Web Forms will be based. On every webform I want to display the username and the e-mail address of the users who will be accessing my site.

But I don''t have any clue whatsoever how to perform a AD query from my Masterpage.master

Beneath is what I created so for.
- So where should I query AD?
- How would the code look like?
- Can I use my Toolbox for this?
- Username should be displayed at USer_Name (see code beneath)
- E-MailAddress should be displayed at E-Mail_adres (see code beneath)

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <asp:ContentPlaceHolder id="head" runat="server">
    </asp:ContentPlaceHolder>
    <style type="text/css">
        .style1
        {
            width: 100%;
            height: 140px;
        }
        .style4
        {
            width: 107px;
            margin-left: 40px;
        }
        #form1
        {
            height: 545px;
        }
        .style10
        {
            font-family: "Times New Roman", Times, serif;
            color: #3333FF;
            font-size: xx-large;
            font-weight: 700;
        }
        .style11
        {
            width: 30%;
        }
        .style12
        {
            width: 18%;
            float: left;
        }
        .style13
        {
            width: 80%;
            float: right;
        }
        .style14
        {
            color: #3333FF;
        }
        .style15
        {
            width: 0%;
            float: left;
            height: 291px;
        }
        .style16
        {
            color: #000000;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table class="style1">
            <tr>
                <td class="style4">
                    <asp:Image ID="Rabobank" runat="server" Height="125px"

                        ImageUrl="~/Images/xyz.png" Width="98px" />
                </td>
                <td class="style10" height="2">
                    <strong>Any Device Portaal</strong></td>
                <td class="style10" height="2">
                    <asp:ContentPlaceHolder ID="Sub_Titel" runat="server">
                    </asp:ContentPlaceHolder>
                </td>
                <td>
                    <asp:Image ID="Image1" runat="server" Height="126px" ImageAlign="Right"

                        ImageUrl="~/Images/SmartPhones.jpg" Width="115px" />
                </td>
            </tr>
        </table>
    </div>
    <asp:Panel ID="Panel1" runat="server" BackColor="#3333FF" BorderColor="#3333FF"

        ForeColor="#3333FF" Height="3px">
        <hr />
    </asp:Panel>
    <br />
    <table align="right" class="style11">
        <tr>
            <td>
                Gebruikersnaam:</td>
            <td>
                USer_Name</td>
        </tr>
        <tr>
            <td>
                E-Mail adres</td>
            <td>
                E-Mail_adres</td>
        </tr>
    </table>
    <br />
    <br />
    <br />
    <table align="left" class="style12">
        <tr>
            <td style="text-decoration: underline; font-weight: 700">
                <span class="style14">Handige Links:</span><br />
                <asp:HyperLink ID="HyperLink_Main_01" runat="server">ICT_Services</asp:HyperLink>
                <br />
                <asp:HyperLink ID="HyperLink_Main_02" runat="server">Blog</asp:HyperLink>
                <br />
                <asp:HyperLink ID="HyperLink_Main_03" runat="server">Manuals</asp:HyperLink>
                <br />
                <br />
                <span class="style14">Navigatie Any Device:<br />
                </span>
                <asp:HyperLink ID="StartPagina_StartPagina" runat="server" CssClass="style16"

                    NavigateUrl="~/Default.aspx">Start Pagina</asp:HyperLink>
                <br />
                <asp:HyperLink ID="StartPagina_Got_Problem" runat="server"

                    NavigateUrl="~/Got_Problem.aspx" style="color: #000000">Problemen met mijn toestel</asp:HyperLink>
                <asp:ContentPlaceHolder ID="HyperLinks" runat="server">
                </asp:ContentPlaceHolder>
            </td>
        </tr>
    </table>
&nbsp;&nbsp;
    <table align="left" class="style15">
        <tr>
            <td bgcolor="#3333FF">
                &nbsp;</td>
        </tr>
    </table>
&nbsp;<table align="right" class="style13">
        <tr>
            <td>
                <asp:ContentPlaceHolder ID="Main_Title" runat="server">
                </asp:ContentPlaceHolder>
                <asp:ContentPlaceHolder ID="Main_Body" runat="server">
                </asp:ContentPlaceHolder>
            </td>
        </tr>
        <tr>
            <td>
                &nbsp;</td>
        </tr>
    </table>
&nbsp;&nbsp;
    </form>
        <div id="footerContent">
        2011 xyz. Alle rechten voorbehouden.
        <br />
        Any Device is onderdeel van abc</div>
</body>
</html>

推荐答案

您可以使用如何从Active Directory获取用户数据 [ http://stackoverflow.com/Problems/637486/how-to-get-the-current-users-active-directory-details-in-c-sharp [ ^ ]

希望对您有所帮助:)
You can take Lables[^] to display username and email address. And try these to get user details from active directory:

How to get User Data from the Active Directory[^]

http://stackoverflow.com/questions/637486/how-to-get-the-current-users-active-directory-details-in-c-sharp[^]

hope it helps :)


这篇关于查询活动目录-当前用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆