Explains how to determine the user to display the list settings for the current user only
And they are taken after applying around this limitation: AND ( = ( Module IIS.AMS02.Of the incident.WinformЗадержанныйL/objectListView1(ObjectListView) ) OR ( = ( User Sergey KOSHEL ) ISNULL ( User) ) )
Code used to build restrictions:
lcs.LimitFunction = FunctionBuilder.BuildAnd(
FunctionBuilder.BuildEqials(vdModule, prv_GenModuleName(ObjectListView)),
FunctionBuilder.BuildOr(
FunctionBuilder.BuildEqials(vdUser, Settings.SettingManager.GetUserName()),
FunctionBuilde.BuildIsNull(vdUser)
));
That is, the user is taken from the Settings.SettingManager.GetUserName(). And there, in turn, either from the specified value, either from AD or from the Environment:
public static string GetUserName()
{
if (username==string.Empty)
{
try
{
System.DirectoryServices.DirectorySearcher ds = new System.DirectoryServices.DirectorySearcher("(&(objectClass=user)(sAMAccountName= "+Environment.UserName+"))",
new string[]{cn});
ds.CacheResults = true;
System.DirectoryServices.SearchResult sr = ds.FindOne();
username = sr.Properties[cn][0].ToString();
}
catch
{
username =Environment.UserName;
}
}
return username;
}