Guid guid = Marshal.GenerateGuidForType(typeof(IServerEnvironment));

UID uid = new UIDClass();

uid.Value = guid.ToString("B");

IEnvironmentManager environmentManager = new EnvironmentManager() as IEnvironmentManager;

IServerEnvironment2 serverEnvironment = environmentManager.GetEnvironment(uid) as IServerEnvironment2;


string
userName = serverEnvironment.UserInfo.Name;


IEnumBSTR
roles = serverEnvironment.UserInfo.Roles;

string role = roles.Next();

do

  role = roles.Next(); 

while (role != null);