If you use Claims Based Auth., you cannot get a proper username with the command ın Infopath:
this.Application.User.LoginName
You ll get something like :
i:0#.|PROVIDERNAME|Username
You can replace the string but it 's not a proper way to do it.
You can use 2 methods:
1. SPUser user = SPContext.Current.Web.CurrentUser;
user.userName would get you the proper name
or
2.
string userName = null;
SPClaimProviderManager mgr = SPClaimProviderManager.Local;
if (mgr != null)
{
userName = mgr.DecodeClaim(SPContext.Current.Web.CurrentUser.LoginName).Value;
}
this.Application.User.LoginName
You ll get something like :
i:0#.|PROVIDERNAME|Username
You can replace the string but it 's not a proper way to do it.
You can use 2 methods:
1. SPUser user = SPContext.Current.Web.CurrentUser;
user.userName would get you the proper name
or
2.
string userName = null;
SPClaimProviderManager mgr = SPClaimProviderManager.Local;
if (mgr != null)
{
userName = mgr.DecodeClaim(SPContext.Current.Web.CurrentUser.LoginName).Value;
}
Hiç yorum yok:
Yorum Gönder