return not breaking loop (c#) -


I am trying to determine if a user is a member of a group or not. However, the following are not being done for some reasons ...

  public boolean memberoff (string sObjectName, string sGroup, bool bIsGroup) {DirectoryEntry dEntry = CreateDirectoryEntry (); DirectorySearcher dSearcher = New Directory Finder (DNTRI); If (BISGroup) DSteure Filter = "(Dictisionname =" + S + Objectname + ")"; Other dSearcher.Filter = "(and (sAMAccountName =" + sObjectName + ") (objectClass = user))"; Search result sResult = dSearcher.FindOne (); If (sResult! = Null) {foreach (sResult.Properties in the object oGroup ["MemberOf"]) {if (oGroup.ToString () == sGroup) is true; And this. Memberoff (Ogroup.Tostring (), S Group, Truth); }     }     return false; } Another change:  

Either it does not work, it really looks like a dumb question ... but if "to be true" loop Do not break;

It is strange that you are calling back this.MemberOf But are ignoring the results. Perhaps you mean this:

  if (oGroup.ToString () == sGroup) {return true; } Other {bull is member = it.memberoff (oggup.tostering (), s group, truth); If (member) {return is true; }}  

The statement of your return can not be seen to exit the loop, because when you make a continuous call you have a loop inside the loops inside your loop, your call Check the stack - You should notice that MemberOf appears many times and when you come back one of them disappears, after making the above changes, it will return correctly. Unlock the stack.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -