Re: Prepopulate Messenger Contact list

  •  10-29-2010, 3:18 AM

    Re: Prepopulate Messenger Contact list

    Hi strikingknife,
     
    In you chat provider, you have the below code. In this method we provide the "loginName" for you to get the user, so please do not use the current user string LoginName = System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString();  to get the user info.
     
    Try change
     
     SPUser mSPUser = mWeb.AllUsers[LoginName]; 
     
    To
     
     SPUser mSPUser = mWeb.AllUsers[loginName]; 
     
    1. public override bool GetUserInfo(string loginName, ref string nickName, ref bool isAdmin)  
    2.         {  
    3.             bool User = false;  
    4.             string NickName = string.Empty;  
    5.             string LoginName = System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString();  
    6.             bool Admin = false;  
    7.             SPSecurity.RunWithElevatedPrivileges(delegate()  
    8.             {  
    9.                 using (SPSite mSite = new SPSite(GetCurrentSiteURL()))  
    10.                 {  
    11.                     using (SPWeb mWeb = mSite.OpenWeb())  
    12.                     {  
    13.                         SPUser mSPUser = mWeb.AllUsers[LoginName];  
    14.                         if (mSPUser == null)  
    15.                         {  
    16.                             User = false;  
    17.                         }  
    18.   
    19.                         if (mSPUser.IsSiteAdmin == true)  
    20.                         {  
    21.                             Admin = true;  
    22.                         }  
    23.   
    24.                         User = true;  
    25.                         NickName = Convert.ToString(mSPUser.Name);  
    26.   
    27.                     }  
    28.                 }  
    29.             });  
    30.   
    31.             nickName = NickName;  
    32.             isAdmin = Admin;  
    33.             return User;  
    34.   
    35.         }  
    Regards,
     
    Ken 
View Complete Thread