VAADAdmin Posted December 13, 2006 Share Posted December 13, 2006 Below I have a snippet of code. I am using string split to get the distinguished name of a user. (cn=user,ou=accounts,dc=domain,dc=com). I am returning the string and want to strip off the cn=user part to return just the last part of the DN. The problem I am running into is that the number of strings[x] that I have can change with "," as the delimiter. So the subtree can be deeper in Active Directory such as $strDestinationOU[7] and some maybe $strDestinationOU[10]. I would like to just return everything after "cn=user," no matter the length of the remaining string, but I cannot find a solution as of yet. $strDestinationOU = StringSplit($strUserDN, ',') $destinationString = $strDestinationOU[2] & "," & $strDestinationOU[3] & "," & $strDestinationOU[4] & "," & $strDestinationOU[5] & "," & $strDestinationOU[6] & "," & $strDestinationOU[7] & "," & $strDestinationOU[8] MsgBox(64,"",$DestinationString) Link to comment Share on other sites More sharing options...
Markus Posted December 13, 2006 Share Posted December 13, 2006 (edited) $strDestinationOU[0] contains the number of splitted strings, so just do: $strDestinationOU = StringSplit($strUserDN, ',') For $i=2 To $strDestinationOU[0] If $i<$strDestinationOU[0] Then $destinationString =$destinationString & $strDestinationOU[$i] & "," Else $destinationString =$destinationString & $strDestinationOU[$i] EndIf Next MsgBox(64,"",$DestinationString) Edited December 13, 2006 by Markus "It's easier to disintegrate an atom than a prejudice." (A.Einstein)---------------------------------------------------------------------------My C++ - tools:Tidy tool-->indents your c++ sourceCleanscript --> cleans autoit-code before compiling (co-author: peethebee)My tools:GUIBuilder-->build your window and get the source; german versionMy Games:OnlineGameCenter-->Online Chess and Connect4 with a rtf-chatSnake-->including a level editor to build your own levelsTetris-->the well known game, big funOther things:Tower of Hanoi-->perfect riddler with graphic output Link to comment Share on other sites More sharing options...
VAADAdmin Posted December 14, 2006 Author Share Posted December 14, 2006 Thank you for you help, got it working. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now