草庐IT

aster_users

全部标签

C# 事件目录 : Get domain name of user?

我知道以前有人问过这种类型的问题,但现在其他方法都不行。就目前而言,我们的Windows服务轮询AD,给定一个LDAP(即LDAP://10.32.16.80)和该AD服务器中要搜索的用户组列表。它检索那些给定组中的所有用户,同时递归地在这些组中搜索更多组。然后将每个用户添加到另一个应用程序已验证用户列表。应用程序的这一部分运行成功。但是,我们需要每个用户的友好域名(即他们的登录域/用户名的一部分)因此,如果有一个用户是TEST域的一部分,名为Steve:TEST/steve是他的登录名。我能够在AD中找到史蒂夫,但是我还需要“TEST”与他的AD信息一起存储。同样,通过使用目录搜索器

c# - 登录成功后User.Identity.IsAuthenticated为false

登录成功后需要直接获取UserIdGuid。以下代码不起作用:if(Membership.ValidateUser(txtUsername.Value,txtPassword.Value)){FormsAuthentication.SignOut();FormsAuthentication.SetAuthCookie(txtUsername.Value,true);if(HttpContext.Current.User.Identity.IsAuthenticated){//doesn'trunGuidpuk=(Guid)Membership.GetUser().ProviderUse

c# - 如何在 Asp.Net MVC 4 中模拟 HttpContext.User.Identity.Name

我在Controller中有使用HttpContext的代码publicActionResultIndex(){varcurrentUser=HttpContext.User.Identity.Name;......}当尝试像这样使用NUnit编写测试时[Test]publicvoidCanDisplayRequest(){//Actvarresult=(ViewResult)_requestController.Index();//AssertAssert.IsInstanceOf(resut.Model);}测试将失败,因为它找不到HttpContext那么我如何模拟HttpCon

c# - 具有 HttpContext.Current.User.Identity.IsAuthenticated 的 Webmethods 在 Azure 上不活动后停止工作

我正在使用使用Ajax(json)/Webmethod函数的页面测试Azure服务器。其中一些函数在运行代码之前会检查HttpContext.Current.User.Identity.IsAuthenticated。不幸的是,如果用户已登录并且页面没有向服务器发出完整的回发请求,则只有那些检查HttpContext.Current.User.Identity.IsAuthenticated的webmethods函数会在一对夫妇之后完全停止运行分钟没有给出任何错误。他们甚至不运行else代码块(见下文)。我已经在本地服务器上测试了这些页面,一切正常,即使在长时间不活动之后也是如此。这是

c# - SignalR OnDisconnected - 处理聊天室 "User is Online"的可靠方法?

我正在实现一个聊天室。到目前为止,一切都很好——用户可以通过JS客户端从他们的浏览器发送消息,我可以使用C#客户端来做同样的事情——这些消息被广播给其他用户。现在,我正在尝试实现“在线用户”。我的方法如下:OnConnected-将数据库中的用户更新为IsOnline=trueOnDisconnected-如果用户没有任何其他连接,则将数据库中的用户更新为IsOnline=false我将状态存储在数据库中,因为无论如何我都必须在数据库中查询用户缩略图-这似乎是在中心使用词典的一种简单替代方法。我遇到的问题是OnDisconnected并不总是为每个客户端ID调用-陈旧的连接阻止了“如果

c# - SQL 错误 : Incorrect syntax near the keyword 'User'

我正在使用SQL将数据插入到使用C#的SQL数据库文件中,如下所示。Stringcs=System.Configuration.ConfigurationManager.ConnectionStrings["connection1"].ConnectionString;SqlConnectionconn=newSqlConnection(cs);Stringsql="INSERTINTOUser(login,password,status)"+"VALUES(@login,@password,@status)";SqlCommandcomm=newSqlCommand(sql,conn

c# - HttpContext.Current.User.Identity.Name 如何知道存在哪些用户名?

这不一定是个问题,我只是好奇它是如何工作的。我有一个方法:publicstaticboolUserIsAuthenticated(){boolisAuthed=false;try{if(HttpContext.Current.User.Identity.Name!=null){if(HttpContext.Current.User.Identity.Name.Length!=0){FormsIdentityid=(FormsIdentity)HttpContext.Current.User.Identity;FormsAuthenticationTicketticket=id.Tick

c# - System.IO.Exception 错误 : "The requested operation cannot be performed on a file with a user-mapped section open."

我在写入XML文件时收到一个非常奇怪的IOException:System.IO.IOException:Therequestedoperationcannotbeperformedonafilewithauser-mappedsectionopen.atSystem.IO.__Error.WinIOError(Int32errorCode,StringmaybeFullPath)atSystem.IO.FileStream.Init(Stringpath,FileModemode,FileAccessaccess,Int32rights,BooleanuseRights,FileSh

c# - 如何使用最小起订量模拟 Controller.User

我有几个ActionMethods可以像这样查询Controller.User的角色boolisAdmin=User.IsInRole("admin");在那个条件下方便地行动。我开始用这样的代码对这些方法进行测试[TestMethod]publicvoidHomeController_Index_Should_Return_Non_Null_ViewPage(){HomeControllercontroller=newHomePostController();ActionResultindex=controller.Index();Assert.IsNotNull(index);}并

c# - 为 WebClient 请求设置 User-Agent header

为WindowsPhone7的WebClient请求设置User-Agentheader的正确方法是什么?我找到了2个选项,但不确定哪一个是正确的。考虑WebClient对象:WebClientclient=newWebClient();我看到了2个选项:使用以下方法设置用户代理:client.Headers["User-Agent"]="myUserAgentString";使用WebHeaderCollection设置用户代理:WebHeaderCollectionheaders=newWebHeaderCollection();headers[HttpRequestHeader.