<authentication mode="Windows"> <forms loginUrl="~/TTracker/Login.aspx" timeout="600"></forms> </authentication> <authorization> <deny users="?"/> <allow users="*" /> </authorization> <identity impersonate="true" />
using System.DirectoryServices; using System.DirectoryServices.AccountManagement; using (HostingEnvironment.Impersonate()) { DropDownList1.Items.Add(new ListItem("-Select-", "")); string grpname = "Group1"; PrincipalContext ctx = new PrincipalContext(ContextType.Domain, "domain"); GroupPrincipal grp = GroupPrincipal.FindByIdentity(ctx, IdentityType.SamAccountName, grpname); if (grp != null) { foreach (Principal p in grp.GetMembers(false)) { DropDownList1.Items.Add(p.SamAccountName + "-" + p.DisplayName); } grp.Dispose(); ctx.Dispose(); Console.ReadLine(); } else { Console.WriteLine("We did not find that group."); Console.ReadLine(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)