I am using Asp.net memebership provider for FBA in sharePoint 2013. Please let me know how to dynamically find membership provider name.
Thanks in advance.
I am using Asp.net memebership provider for FBA in sharePoint 2013. Please let me know how to dynamically find membership provider name.
Thanks in advance.
This is quite easy , in CSOM get the current username (if you are logged in with a forms based account) .The username will be of the following format :
"i:0#.f|membership|someone.example.com"
The "i:0#.f|membership|someone.example.com" is the membership provider name. Use javascript substring function to get this section.
To get the current user loginname, use the following code which is also provided here
function GetCurrentUsername()
{
var ctxt = new SP.ClientContext.get_current();
this.website = ctxt.get_web();
this.currentUser = website.get_currentUser();
ctxt.load(currentUser);
ctxt.executeQueryAsync(Function.createDelegate(this, this.onSucceess), Function.createDelegate(this, this.onFail));
}
function onSucceess(sender, args)
{
alert(currentUser.get_loginName());
}
function onFail(sender, args)
{
alert('request failed ' + args.get_message() + '\n'+ args.get_stackTrace());
}
Thanks for the response. My scenario is I am dynamically planning to get membership provider as I have to create token during forms authentication. I found the answer
Hope this code helps someone.
Thanks Rama