this.Label2.Text = user.IsInRole(@"Wicresoft\").ToString();
//Label1.Text = HttpContext.Current.User.Identity.IsAuthenticated.ToString() +" "+ User.Identity.Name;
Label1.Text = GetAllOU(User.Identity.Name);
// Put user code to initialize the page here
}
public string GetAllOU(string strLogin )
{
string str = "";
// Parse the string to check if domain name is present.
int idx = strLogin.IndexOf('\\');
if (idx == -1)
{
idx = strLogin.IndexOf('@');
}
string strDomain;
string strName;
if (idx != -1)
{
strDomain = strLogin.Substring(0, idx);
strName = strLogin.Substring(idx+1);
}
else
{
strDomain = Environment.MachineName;
strName = strLogin;
}
DirectoryEntry obDirEntry = null;
try
{
obDirEntry = new DirectoryEntry("WinNT://" + strDomain + "/" + strName);
System.DirectoryServices.PropertyCollection coll = obDirEntry.Properties;
object obVal = coll["FullName"].Value;
str = obVal.ToString();
}
catch (Exception ex)
{
str = "";
Trace.Write(ex.Message);
}
return str;