Hi -
I have a process that needs to get information about a SoftPro user. I have their networkLogin (i.e. DOMAIN\UserName) - I wrote this code but the user object is always returned as NULL.
Any advice?
ISecurityManager sm = selectServer.GetService<ISecurityManager>();
//Get your current user
ISecurityUser userInfo= sm.GetUser(AuthenticationScheme.Windows, "DomainName\Jane.Doe");
if (userInfo!= null)
{
return userInfo.EmailAddress;
}
else
{
return "";
}
GetUser API
-
- Posts: 1377
- Joined: Wed Jan 15, 2014 3:50 pm
- Location: Raleigh, NC
- Contact:
Re: GetUser API
Your approach doesn't work because the second parameter for GetUser() is expecting a Guid string. The code below is used to first get the light-weight ISecurityIdentity object for the user. Then the code gets the heavy-weight object with more user information by looking it up with the user Guid.
Code: Select all
ISecurityManager secMgr = RuntimeContext.GetService<ISecurityManager>();
ISecurityIdentity existingIdentity = secMgr.Identities
.Where(t => t.Authority == AuthenticationScheme.Windows
&& t.Name == "SOFTPRO\\fancypants")
.FirstOrDefault();
if (existingIdentity != null)
{
ISecurityUser userInfo = secMgr.GetUser(existingIdentity.ID);
return userInfo.EmailAddress;
}
Bob Richards, Senior Software Developer, SoftPro
Re: GetUser API
Many thanks Each time I continue to learn about SoftPro and the features and how to use them. Thanks agao