Error creating a user in active directory

I am trying to create a user in 2005 via the system.directoryservices calls and I get an error that I am not able to figure out.

I am logged in as the domain administrator and am able to change properties on existing users.  I have included the function I have created that is giving me the error.

The Error is:

An invalid dn syntax has been specified. (Exception from HRESULT: 0x80072032)
Public Function Create_User(ByVal deOU_To_Hold_User As System.DirectoryServices.DirectoryEntry, ByVal strSAM_ACCT As String) As System.DirectoryServices.DirectoryEntry
		Dim deNew_User As DirectoryServices.DirectoryEntry
		Dim deUsers_In_OU As DirectoryServices.DirectoryEntries
			deUsers_In_OU = deOU_To_Hold_User.Children
			deNew_User = deUsers_In_OU.Add(strSAM_ACCT, "User")
			Create_User = deNew_User
		Catch ex As Exception
			mstrErrorText = ex.Message
			Create_User = Nothing
		End Try
	End Function

Open in new window

Who is Participating?
Dustin HopkinsConnect With a Mentor Managing MemberCommented:
try changing your add statement to this
deNew_User = deUsers_In_OU.Add("CN=" & strSAM_ACCT, "user")

Dustin HopkinsManaging MemberCommented:
Also here is a really good site for common active directory operations, using .net/c#.
RJLemonAuthor Commented:
Hi Dusion,

Did you mean to provide a link or URL.  I don't see it.

I will try your suggestions in a few minutes.

Dustin HopkinsManaging MemberCommented:
Oops: I guess I'm trying to do too many things at once.
here is the link
RJLemonAuthor Commented:
So simple a solution for such a hard problem.

Greatly appreciated.
All Courses

From novice to tech pro — start learning today.