1

Need To Get SpUser LoginName

My References Code:-

using (var site = new SPSite(SPContext.Current.Web.Url))
            {


                SPServiceContext serviceContext = SPServiceContext.GetContext(site);
                var profileManager = new UserProfileManager(serviceContext);

                    var configProperties = new ConfigurationProperties();

                    var spUsers = site.RootWeb.SiteUsers.Cast<SPUser>().ToList();

                foreach (UserProfile userProfile in profileManager)
                {


                    }
}
1

You can get the login name from the user profile as illustrated below:

  foreach (UserProfile userProfile in profileManager)
  {
    string loginName = userProfile["AccountName"][0] as string;
    Console.WriteLine(loginName);
  }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.