forsters
asked on
Query AD from asp.net c#
Hi Experts,
This is a follow-on from an earlier question, I'm just feeling my way into querying AD from an asp.net c# web app:
http://www.experts-exchang e.com/Prog ramming/La nguages/.N ET/ASP.NET /Q_2786742 3.html
In the code below I have a few lines that get the identity of the person logged in, I'd like to use this for my bool test so that I now look up the person logged in and confirm they exist in AD.
My plan is to then go on and retrieve certain details based on their identity:
Be grateful if someone could show me how to use my Session["username"] in the ("domain\\username") path, I have tried a few variations but clearly missing the obvious here.
This is a follow-on from an earlier question, I'm just feeling my way into querying AD from an asp.net c# web app:
http://www.experts-exchang
In the code below I have a few lines that get the identity of the person logged in, I'd like to use this for my bool test so that I now look up the person logged in and confirm they exist in AD.
My plan is to then go on and retrieve certain details based on their identity:
Be grateful if someone could show me how to use my Session["username"] in the ("domain\\username") path, I have tried a few variations but clearly missing the obvious here.
protected void Page_Load(object sender, EventArgs e)
{
System.Security.Principal.IPrincipal user;
user = System.Web.HttpContext.Current.User;
System.Security.Principal.IIdentity identity;
identity = user.Identity;
Session["username"] = identity.Name.Substring(identity.Name.IndexOf(@"\") + 1);
bool test = IsExistInAD("domain\\username");
if (test == true)
{
Response.Write("user exists");
}
else
{
Response.Write("user doesn't exist");
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Perfect thank you, I knew it would be something simple, was trying to contain the whole path in my " ", sighs.
Thank you so much
Thank you so much
string user;
usr="domain\\" + Session["username"] ;
bool test = IsExistInAD(USR);