ITsolutionWizard
asked on
asp.net active directory
I have below codes written in asp.net/c# and don't know how to call it?
Like Response.write IsUserInTheGroup("managerG roup","Joh nY") does not work...
public static bool IsUserInTheGroup(GroupPrin cipal group, string userName)
{
string userNameLowerCase = userName.Trim().ToLower();
//Not in the group because username is emplty
if (String.IsNullOrEmpty(user NameLowerC ase) == true)
{
return false;
}
foreach (Principal result in group.Members)
{
if (result is UserPrincipal)
{
if (result.SamAccountName.Tri m().ToLowe r().Equals (userNameL owerCase) == true)
{
return true;
}
}
}
//Not found in the group
return false;
}
Like Response.write IsUserInTheGroup("managerG
public static bool IsUserInTheGroup(GroupPrin
{
string userNameLowerCase = userName.Trim().ToLower();
//Not in the group because username is emplty
if (String.IsNullOrEmpty(user
{
return false;
}
foreach (Principal result in group.Members)
{
if (result is UserPrincipal)
{
if (result.SamAccountName.Tri
{
return true;
}
}
}
//Not found in the group
return false;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
assume I want to get a list instead of true/false. Sorry for the last min. change.
ASKER